我想要符合GLMM Poisson模型计数。我有121个科目(-print0
),我观察到每个科目有8个泊松计数(find
):它们对应于2种类型的事件(-exec sed -i '' ... {} +
)x 4个句点(subject
)。
count
我想要的是什么:
event
,(2)period
,(3)'data.frame': 968 obs. of 4 variables:
$ count : num 4 0 2 3 3 0 1 0 8 14 ...
$ subject: num 1 1 1 1 1 1 1 1 2 2 ...
$ event : Factor w/ 2 levels "call","visit": 2 2 2 2 2 2 2 2 1 1 ...
$ period : Factor w/ 4 levels "period_1","period_2",..: 1 2 3 4 1 2 3 4 1 2 ...
的随机效应。subject
,(2)subject:visit
,(3)subject:event
的随机效应我设法得到了什么:
我相信我正在正确设置模型公式,我正在为固定效果参数设置所需的先验:
subject
我挣扎的是:
subject:visit
,(2)subject:event
,(3)## define some priors
prior <- c(prior_string("normal(0,10^3)", class = "b"),
prior_string("normal(0,10^3)", class = "b", coef = "eventvisit"),
prior_string("normal(0,10^3)", class = "b", coef = "eventvisit:periodperiod_2"),
prior_string("normal(0,10^3)", class = "b", coef = "eventvisit:periodperiod_3"),
prior_string("normal(0,10^3)", class = "b", coef = "eventvisit:periodperiod_4"),
prior_string("normal(0,10^3)", class = "b", coef = "periodperiod_2"),
prior_string("normal(0,10^3)", class = "b", coef = "periodperiod_3"),
prior_string("normal(0,10^3)", class = "b", coef = "periodperiod_4"))
## fit model
fit1 <- brm(count ~ event + period + event:period + (1|subject) + (0 + event|subject) + (0 + period|subject),
data = data.long, family = poisson(),
prior = prior,
warmup = 1000, iter = 4000, chains = 4,
cores = 7)
的效果答案 0 :(得分:1)
关于您想要的内容:您能否请subject:visit
和subject:event
更详细地解释您想要的内容?目前,我无法确定您的模型是否正确指定用于您的目的。
关于先辈:
prior_string("normal(0,10^3)", class = "b")
,则无需为每个系数再次指定先前的系数。为整个前一课程全局设置就足够了。请注意,给定响应和预测变量的比例,正常(0,1000)是如此之宽,以至于几乎没有影响。你也好好把它留下来。normal(0, sigma_x)
个先验。无需担心它们。class = "sd"
在随机效果SD上设置先验。例如prior_string("cauchy(0, 5)", class = "sd")
。我明确地鼓励你不特别使用统一的先验,因为它们有一个参数的硬上限(标准偏差),它没有理论上限。