3
$\begingroup$

I want to build a linear repeated measures mixed-effects model in R. I have a sample N=105 that completed measures at two timepoints (baseline and follow-up), and small group (N= 29) that received an intervention between baseline and follow-up. I want to know what variables (i.e. scores) are associated with viral load, overall, at both time points, besides the intervention. In other words, I want to control for the random effects of the intervention and time as I am not interested in these variables and investigate what other variables are associated with viral load, overall, across both timepoints. I want to do a mixed-effects model because it will be able to account for the fact that each participant did the measure twice.

The variables in the model are: Outcome variable: log viral load; Random effect variables: time (baseline and follow-up), groups_2 (intervention and no intervention), record_id (participant ID); Fixed effect variables: measure_score_1, measure_score_2, dem_age, dem_gender.

This is the model I want to build in R: model1 <- lmer(log_viral_load~ measure_score_1+ measure_score_2+ dem_gender+dem_age+ (1|groups_2/record_id), data= bothdata)

My question is: Are the specifications in model1 correct to answer the question? Specifically, do I need to incorporate the variable time as a random effect for it to account for the fact that each participant did each measure twice or if including record_id as a random effect does this?

Or do I need to include time as a random effect like this: model2 <- lmer(log_viral_load~ measure_score_1+ measure_score_2+ dem_gender+dem_age+ (1|groups_2/record_id)+ (1 |time), data= bothdata)

Thank you for your help.

$\endgroup$

1 Answer 1

4
$\begingroup$

Are the specifications in model1 correct to answer the question?

No.

The random structure (1|groups_2/record_id) does not make sense. Assuming that groups_2 is the factor which records whether a participant is in one of the two groups, and record_id is a factor which identifies the participant, then this model will estimate a variance for groups_2 assuming a normal distribution, from only 2 observations of it. groups_2 should therefore be a fixed effect. It is irrelavant that you are not interested in this fixed effect itself (it is there to adjust for the intervention).

do I need to incorporate the variable time as a random effect

No, because, as above, you have only 2 time points. The usual approach is to fit time as a fixed effect. It is also good practice to centre time (eg -0.5 and 0.5, or -1 and 1), particularly if you then decide to allow each particpant to have a different slope with respect to time (ie. a different response to the intervention).

So I would start with the model:

og_viral_load ~ groups_2 + time + measure_score_1 + measure_score_2 + dem_gender + dem_age + (1|record_id)

or with random slopes for time (provided the data support such a model):

og_viral_load ~ groups_2 + time + measure_score_1 + measure_score_2 + dem_gender + dem_age + (time|record_id)

If you want the slope for time to differ between the groups then could also fit an interaction between them.

Finally, regarding the research question, rather than just adding all your variables to the model and looking for which one(s) are significant, it is important to consider the possible causal relations between ALL the variables, otherwise you can end up with a lot of problems to do with mediation and colliders. See the accepted answer here for more details about this:
How do DAGs help to reduce bias in causal inference?

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.