Residual error covariance structure in longitudinal mixed models

When we use the mixed effects model for longitudinal data (repeated measures within subjects), with random intercepts for subjects, I know that the shortcoming when using packages such as lme4 in R is that intra-class correlation is constant within subjects. That means that the correlation between time points 1 and 2 is the same as between 1 and 5, but we often expect that the correlation would fall the farther away the time points are.

In this answer by Dimitris Rizopoulos:

What is the procedure to specify a random effects design matrix?

he says:

... in longitudinal data, you want to include functions of time in the random effects design matrix to account for the serial correlations.

Can anyone explain what this means, and perhaps give the example ? Is it as simple (in simple cases!) as specifying a linear random slope for time ?

Also, can anyone explain how this accounts for autocorrelation in mixed models ? I know that some software such as nlme in R allows the specification of and AR1 and other structures, which I can understand. I just don't understand how using specifying "functions of time in the random effects design matrix" works.

• Correct, (time | subj) denotes linear random slopes, (time + I(time^2) | subj) denotes linear and quadratic random slopes (it is better to use (poly(time, 2) | subj)), and (ns(time, 2) | subj) denotes a natural cubic spline for the time effect. In all of these expressions, the random intercepts are included by default. Nov 27, 2023 at 19:39