[R-sig-ME] Diagonal covariance matrix of random effects when using natural splines in lme4

xavier piulachs xavierpiulachs at hotmail.com
Tue Nov 28 17:39:05 CET 2017


Hi everyone,

I'm trying to fit a longitudinal model with natural cubic splines with 2 inner knots, 
where I want to assume a diagonal covariance matrix for the random effects (i.e. 
uncorrelated random effects). Let's say, I'm using the well-known data "sleepstudy" 
from the "lme4" package.

First, I run the model trough "nlme" package:
 
model.nlme <- lme(Reaction ~ ns(Days, df = 3), 
                  random = list(Subject = pdDiag(form = ~ ns(Days, df = 3))), 
                  data = sleepstudy)

An the output indicates that there is no correlation between random effects:

Random effects:
 Formula: ~ns(Days, df = 3) | Subject
 Structure: Diagonal
        (Intercept) ns(Days, df = 3)1 ns(Days, df = 3)2 ns(Days, df = 3)3 Residual
StdDev:       25.78             57.12             63.62             46.61    20.97

However, I do not know how to run the same model under lme4 package. I tried:

model.lme4 <- lmer(Reaction ~ ns(Days, df = 3) + (ns(Days, df = 3) || Subject),
                    data = sleepstudy)

But, as shown by the output, I only have independence regarding the random 
intercept effect (which, by default, is not included in the B-spline basis):

Random effects:
 Groups    Name              Variance Std.Dev. Corr     
 Subject   (Intercept)         605.9   24.62             
 Subject.1 ns(Days, df = 3)1  3210.5   56.67             
           ns(Days, df = 3)2  4183.9   64.68    0.57     
           ns(Days, df = 3)3  2296.3   47.93    0.44 0.72

Any guidance on this issue would be much appreciated.


More information about the R-sig-mixed-models mailing list