2
$\begingroup$

I'm trying to build mixed-effects models but having trouble working out what the best model structure is. I have 4 variables: individual ID, time $t$, biomarker $x$ and biomarker $y$, both continuous and expected to change over time. Gradients and intercepts for both $x$ and $y$ will vary by each individual, but the hypothesis is that a rise in $x$ will correlate with a rise in $y$. I'm using lme4 in R.

From this tutorial I see they run

lmer(weight ~ Time * Diet + (1 + Time | Chick), data=ChickWeight, REML=F)

for a similar data structure except that Diet is constant over time for each chick, whereas my $x$ is continuous and time-dependent. Do I need to change the model structure to account for this, or would:

lmer(y ~ t * x + (1 + t | id), data=df)

be sufficient for my problem?

$\endgroup$

2 Answers 2

1
+50
$\begingroup$

I am a little unclear what your question is, and in particular what you want to know from the interaction of time-varying x with t. But let me elaborate on your current model, which is:

lmer(y ~ t * x + (1 + t | id), data=df)

This models y as a linear function of time, x, and the interaction of x and t. It further allows for the linear association between time and y to vary across persons (random slope - (1+t|id). So each person gets their own linear rate of change in y. The interaction between time and x assesses whether the time-varying association between x and y is different depending on the value of t. Or equivalently, whether the linear rate of change in y varies as a function of time-varying x.

Interactions between time and a time-varying variable can be difficult to interpret. Accordingly, it may be more meaningful to think about whether the rate of change in y depends on an individual's average value on x. This would entail calculating the mean value of x for each individual, e.g. using dplyr:

df <- df %>% group_by(id) %>% mutate(pmn_x=mean(x)) %>% ungroup()
lmer(y ~ t * x + pmn_x + pmn_x:t + (1 + t | id), data=df)

This model is also advantageous because by including pmn_x, you separate out the time-varying portion of x from the time-invariant portion of x (pmn_x). And because both interact with t, the interaction is also separated into a pure within-person interaction effect (t*x) and a pure between-person interaction effect (pmn_x:t).

Again, whether this is useful depends on what your question is.

$\endgroup$
1
  • $\begingroup$ Thanks a lot for this answer! Very helpful and provides an improvement on my existing approach. Exactly what I was looking for $\endgroup$
    – E. Rei
    Commented May 4, 2020 at 10:04
1
$\begingroup$

It is difficult to answer if this model is "sufficient". It would be best that you start from a model that translates into model terms your research question, and see what you learn from the data regarding this question using the postulated model. Also, note that mixed models require specifying two parts, namely, the fixed- and random-effects parts. Most often, interest is in the fixed-effects part, but to get efficient (and unbiased in case you have missing data) inferences for this part, you also need to suitably specify the random-effects part.

You may have a look regarding these issues in my course notes.

$\endgroup$
1
  • 1
    $\begingroup$ Thanks for this information. But doesn't it just restate the information in the question? I had a model that translated the research question into model terms, and I specified fixed and random effects in the question. I wanted to check that I had done that correctly for the research question and model given. $\endgroup$
    – E. Rei
    Commented May 3, 2020 at 11:42

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.