I am moving from StackOverflow looking for statistical aspects of the code.
My work is based on an lifestyle intervention made up 3 groups (1, 2 and 3) with measurements at 2 points separated by 12 months (pre- and post-intervention). The sample size is around 50 participants/group, and the response variables are genes, just in case.It is proven which covariates have largely affect the outcome in this studies, such as age or sex.
My understanding of linear mixed models is limited, and constrained to their utility of the general aspects.
Referring to package choice, nlme package allows heterocedasticity, and more flexible covariance structures in the random effects compared to lme4. This is way I picked nlme over lme4.
Having decided this I could possibly have:
- lme(gene ~ time:group + age + sex, random= ~ time|id , method="REML", data=tmp, control = lmeControl(opt = "optim"), na.action = na.omit)
- lme(gene ~ time:group + group + age + sex, random= ~ time|id , method="REML", data=tmp, control = lmeControl(opt = "optim"), na.action = na.omit)
- lme(gene ~ time:group + group + time + age + sex, random= ~ time|id , method="REML", data=tmp, control = lmeControl(opt = "optim"), na.action = na.omit)
- lme(gene ~ time:group + time + age + sex, random= ~ time|id , method="REML", data=tmp, control = lmeControl(opt = "optim"), na.action = na.omit)
I don't really understand the difference in including the time effect alone or not. If understood it correctly the grup_int alone captures intra-individual variance (through the intercept). Not sure if time alone (model4) means anything or at least anything contributing the model. I checked model nÂș 2 and 3 don't change at least in the interaction terms.
Thanks in advance
UPDATE
The results obtained by the model2 for the time:grup_int interaction are like this:
Does it mean that the interaction term time:grup_int1 is not significant compared to the other 2 groups? How is this possible when time:grup_int2 is significant? I guess this is not the meaning becaus this would be a overall p-value as a simple ANOVA,but I would get a single value. Which is the meaning then?
Best Answer
lme4 is often a popular choice because it will warn you more when your models don't fit well. In your case, you have only two time points per individual, but you are fitting a model with both a random intercept and a random slope. You don't have enough data to fit a random slope. Your random effect term should instead be
random= ~ 1|id
. Now you are fitting an interaction term that is only between fixed effects (time:group
). The standard rules for interactions apply, you need to include both time and group as separate variables (gene ~ time:group + group + time
).Edit
Here's a worked example.