# Testing simultaneous and lagged effects in longitudinal mixed models with time-varying covariates

I was recently told that it was not possible to incorporate time-varying covariates in longitudinal mixed models without introducing a time lag for these covariates. Can you confirm / deny this? Do you have any references on this situation ?

I propose a simple situation to clarify. Suppose that I have repeated measures (say over 30 occasions) of quantitative variables (y, x1, x2, x3) in 40 subjects. Each variable is measured 30 times in each subject by a questionnaire. Here the final data would be 4 800 observations (4 variables X 30 occasions X 40 subjects) nested in 40 subjects.

I would like to test separately (not for model comparison) for :

• simultaneous (synchronous) effects : the influence of x1, x2, and x3 at time t on y at time t.
• lagged effects : the influence of x1, x2, and x3 at time t-1 on y at time t.

I hope everything is clear (I'm not a native English speaker !).

For instance, in R lmer{lme4}, the formula with lagged-effects is :

lmer(y ~ lag1.x1 + lag1.x2 + lag1.x3 + (1|subject))


where y is the dependent variable at time t, lag1.x1 is the lagged independent variable x1 at the individual level, etc.

For simultaneous effects, the formula is :

lmer(y ~ x1 + x2 + x3 + (1|subject))


Everything is running well and it gives me interesting results. But is it correct to specify a lmer model with synchronous time-varying covariates or have I missed something ?

Edit: Moreover, is it possible to test both simultaneous and lagged effects at the same time ? , For instance :

lmer(y ~ x1 + x2 + x3 + lag1.x1 + lag1.x2 + lag1.x3 + (1|subject))


Theoretically, it makes sense to test competition between concurrent vs. lagged effects. But is it possible with lmer{lme4} in R, for example ?

I know this is probably too late for your benefit, but perhaps for others I will provide an answer.

You can include time-varying covariates in a longitudinal random-effects models (see Applied Longitudinal Analysis by Fitzmaurice, Laird and Ware, 2011 and http://www.ats.ucla.edu/stat/r/examples/alda/ specifically for R – use lme). Interpretation of trends depends on if you code time as categorical or continuous and your interaction terms. So for instance, if time is continuous and your covariates x1 and x2 are binary (0 and 1) and time-dependent, the fixed model is:

$$yij = \beta_0 + \beta_1x_{1ij} + \beta_2x_{2ij} + \beta_3time_{ij} + \beta_4 \times (x_{1ij} * time_{ij}) + \beta_5 \times (x_{2ij} * time_{ij})$$

i is for ith person, j is for jth occasion

$\beta_4$ and $\beta_5$ capture the difference in trends between levels of $x_1$ and $x_2$ while accounting for change over time in $x_1$ and $x_2$. Unless you specify $x_1$ and $x_2$ as random effects, correlations between the repeated measures will not be taken into account (but this needs to be based on theory and can get messy if you have too many random effects - i.e., model won’t converge). There is also some discussion about centering time-dependent covariates to remove bias, although I have not done this (Raudenbush & Bryk, 2002). Interpretation, in general, is also more difficult if you have a continuous time-dependent covariate.

$\beta_1$ and $\beta_2$ capture the cross-sectional association between $x_1$ and $y$ and $x_2$ and $y$ at the intercept ($\beta_0$). The intercept is where time is zero (baseline or wherever you centered your time variable). This interpretation could also be changed if you have a higher order model (e.g., quadratic).

You would code this in R as something like:

model<- lme(y ~ time*x1 + time*x2, data, random= ~time|subject, method="")


Singer and Willet appear to use ML for “method” but I have always been taught to use REML in SAS for overall results but compare the fit of different models using ML. I would imagine you could use REML in R too.

You can also model the correlation structure for y by adding to the previous code:

correlation = [you’ll have to look up the options]


I am not sure I understand your reasoning for only being able to test lagged effects. I am not familiar with modeling lagged effects so I can’t really speak to that here. Perhaps I am wrong, but I would imagine that modeling lagged effects would undermine the usefulness of mixed models (e.g., being able to include subjects with missing time-dependent data)

• Please double check me that I didn't goof up your equation with the editing, I tried my best with it. – jonsca Jun 19 '13 at 20:55
• Looks good to me :) – MegPophealth Jun 20 '13 at 14:31