我想使用 R 包 glmmTMB
中的 AR1 相关结构来拟合广义线性混合效应模型。检查文档后
...似乎“时间”必须作为随机效应分量的一个因素进行拟合,即
glmmTMB(y ~ ar1(time_fac + 0 | group), data=dat0, family=binomial(link = "logit"))
但是,我想知道拟合这种模型是否有意义:
glmmTMB(y ~ ns(time_cont,3) + ar1(time_fac + 0 | group),
data=dat0, family=binomial(link = "logit"))
这里我将固定效应时间指定为连续的自然样条,同时保留时间作为一个因素对于 ar1 成分。该模型确实适合,但我不确定它是否有意义。另外,我还没有真正看到为什么时间必须编码为 AR1 分量的一个因素的解释,以及为什么我们不能拟合随机斜率?
I would like to fit a generalized linear mixed effect model using an AR1 correlation structure in the R package glmmTMB
. After checking the documentation
... it seems that "time" must be fitted as a factor for the random effects component i.e.
glmmTMB(y ~ ar1(time_fac + 0 | group), data=dat0, family=binomial(link = "logit"))
However, I wondered if it makes sense to fit this kind of model:
glmmTMB(y ~ ns(time_cont,3) + ar1(time_fac + 0 | group),
data=dat0, family=binomial(link = "logit"))
Here I have specified the fixed effect time to be a continuous natural spline whilst retaining time as a factor for the ar1 component. The model does fit, but I am not sure if it makes sense. Also I have not really seen an explanation of WHY time must be coded as a factor for the AR1 component, and why we cannot fit a random slope?
发布评论
评论(1)
总的来说,我认为这个问题对于 CrossValidated 更好,但它太旧了,无法迁移。问题的各个组成部分是统计建模和计算实施问题的混合体。
logit(prob(y(t))) = b0 + b1*y(t-1)
)模拟示例
Overall I think this question is better for CrossValidated, but it is too old to migrate. The individual components of the question are a mixture of statistical modeling and computational implementation questions.
logit(prob(y(t))) = b0 + b1*y(t-1)
)glmmTMB
covariance-structure vignette on construction of structured covariance matrices explains in detail how the covariance matrices for AR1 (and other) structured models are defined; it should explain why time has to be a factor, and why the intercept needs to be suppressed.simulated example