I'm fitting a linear mixed model using the nlme::lme() function in R to analyze repeated measures of a continuous outcome variable over time. My base model is structured as follows:
lme(variable ~ bs(seg, df = 4) * group + fumador + diabetes + hipercol + sexo + hta + educ, random = ~ 1 | id2, correlation = corCAR1(form = ~seg | id2), control = lmeControl(opt = "optim"), data = xxx, method = "REML", na.action = na.exclude) Here:
segis time (in years),groupis an exposure group,id2is the individual identifier,- The correlation structure is CAR(1), assuming repeated measures per individual.
However, I’m working with data pooled from 2 cohorts, and I’m considering whether to model the cohort membership as a random effect. My modified model looks like:
lme(variable ~ bs(seg, df = 4) * group + fumador + diabetes + hipercol + sexo + hta + educ, random = ~ cohort | id2, correlation = corCAR1(form = ~seg | id2), control = lmeControl(opt = "optim"), data = xxx, method = "REML", na.action = na.exclude) My questions is:
- Is this formulation valid, or should cohort be specified at a higher level (e.g., random = ~1 | cohort/id2)? I am not formulating via lmer because of the correlation structure Any clarification on the implications of modeling cohort as a random effect would be appreciated. Thanks!
cohortit would best be used as a fixed factor $\endgroup$