【问题标题】:How do we find the different values for each iteration in rstanarm?我们如何在 rstanarm 中找到每次迭代的不同值?
【发布时间】:2017-10-03 13:49:59
【问题描述】:

我确实在rstanarm 中编写了基本的 GLM 代码。当我执行以下代码时,它给出了所有迭代的预测变量的平均值:

  summary(TestGLM) 
  print(TestGLM)  

我想要我的解决方案在每次迭代中预测变量的值。谁能帮我解决这个问题?

【问题讨论】:

  • 快速浏览了the manualprior_summarysummary.stanreg 你有什么运气吗?如果不是,我想你可以str(TestGLM) 并四处寻找。
  • @EricFail 感谢您的回复。我可以使用 str(TestGLM) 获取值,还可以找到 ggmcmc(TestGLM) 来获取值。我想知道terior_predict(TestGLM) 做了什么,因为它也给了我这些值。如果您对后验预测()有任何想法,请告诉我
  • 查看我上面链接的 rstanarm 手册中的第 23 页。
  • @EricFail 谢谢!

标签: r stan rstan rstanarm


【解决方案1】:

您可以按如下方式提取每个系数的平局:

require(rstanarm)

TestGLM <- stan_glm(mpg ~ wt, data = mtcars)
draws <- as.data.frame(TestGLM)
print(colnames(draws))
str(draws)

# See http://mc-stan.org/rstanarm/reference/as.matrix.stanreg.html

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-01-11
    • 2020-10-08
    • 1970-01-01
    • 1970-01-01
    • 2016-04-03
    • 1970-01-01
    • 2018-09-18
    • 1970-01-01
    相关资源
    最近更新 更多