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

Paul Buerkner paul.buerkner at gmail.com
Tue Nov 28 17:48:04 CET 2017


lme4 does not split the random effects after columns, but after terms and
ns(Days, df = 3) forms a single term.

A workaround would be to compute the basis of the spline manually, add it
to the data frame as separate columns, and then write them explicitely into
the model formula.

2017-11-28 17:39 GMT+01:00 xavier piulachs <xavierpiulachs at hotmail.com>:

> 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.
> _______________________________________________
> R-sig-mixed-models at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>

	[[alternative HTML version deleted]]



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