我试图对序号数据运行一个贝叶斯多级累积模型,并在线阅读brms文档。我的模特看起来就像
model <- brm(bf(y ~ Condition + (Condition|item) + (Condition|subject)),
data = df,
family = cumulative(link="probit", threshold="flexible"),
chains=4,cores=4,iter=2000, prior = prior) 我看到有些文档在指定公式时没有bf()函数,但有些文档则没有。有人能给我解释一下bf()在这里干什么吗?谢谢!
发布于 2022-03-16 09:04:56
bf()函数只是指定一个公式,并且将它用于brm()函数中的简单模型并不是您需要做的事情。你可以在你的例子中删除它。
但是,可以使用bf()函数将公式保存为传递给brm()函数的对象,如下所示:
model_formula <- bf(y ~ Condition + (Condition|item) + (Condition|subject))
model <- brm(model_formula,
data = df,
family = cumulative(link="probit", threshold="flexible"),
chains=4,cores=4,iter=2000, prior = prior) 对于更高级的公式,您可能需要使用bf()函数来分隔模型的不同部分。例如,如果没有将公式包装在bf()中,这样的线性模型就不会运行
model <- brm(bf(y ~ x + (1+x|random_effect), sigma ~ x), ...)下面是一些指向描述更复杂模型的页面的链接,这些页面都使用bf()函数来指定公式:
https://cran.r-project.org/web/packages/brms/vignettes/brms_distreg.html
https://stackoverflow.com/questions/71490829
复制相似问题