Random slope for time in subject not working in lme4

I cannot insert random bias in this model with lme4 (1.1-7):

> difJS<-lmer(JS~Tempo+(Tempo|id),dat,na.action=na.omit)
Error: number of observations (=274) <= number of random effects (=278) for term 
(Tempo | id); the random-effects parameters and the residual variance (or scale
parameter) are probably unidentifiable

      

With nlme it works:

    > JSprova<-lme(JS~Tempo,random=~1+Tempo|id,data=dat,na.action=na.omit)
    > summary(JSprova)
Linear mixed-effects model fit by REML Data: dat
AIC      BIC    logLik
769.6847 791.3196 -378.8424

Random effects:
Formula: ~1 + Tempo | id
Structure: General positive-definite, Log-Cholesky parametrization
            StdDev    Corr
(Intercept) 1.1981593 (Intr)
Tempo       0.5409468 -0.692
Residual    0.5597984       

Fixed effects: JS ~ Tempo 
                Value  Std.Error  DF   t-value p-value
(Intercept)  4.116867 0.14789184 138 27.837013  0.0000
Tempo       -0.207240 0.08227474 134 -2.518874  0.0129
Correlation: 
      (Intr)
Tempo -0.837

Standardized Within-Group Residuals:
        Min          Q1         Med          Q3         Max 
-2.79269550 -0.39879115  0.09688881  0.41525770  2.32111142

Number of Observations: 274
Number of Groups: 139

      

I think this is a lack of data problem, since I have few cases where there is missing data in time, two from DV, but with na.action=na.omit

shouldn't both packages behave the same?

+3


source to share


1 answer


It works with lme

, but I'm 99% sure that your random slopes are indeed blended with residual change. The problem is that you only have two dimensions per subject (or only one dimension per subject in 4 cases - but that's not important here), so a random tilt plus a random intercept for each person gives one random effect for each observation. ...

If you try intervals()

in your fit lme

it will give you a message that variance-covariance matrix is ​​not being identified.

You can force lmer

it to do this by turning off some of the identity checks (see below).

library("lme4")
library("nlme")
library("plyr")

      

Limit the data to just two points per person:

sleepstudy0 <- ddply(sleepstudy,"Subject",
      function(x) x[1:2,])
m1 <- lme(Reaction~Days,random=~Days|Subject,data=sleepstudy0)
intervals(m1)
## Error ... cannot get confidence intervals on var-cov components

lmer(Reaction~Days+(Days|Subject),data=sleepstudy0)
## error

      



If you want, you can force lmer

fit to this model:

m2B <- lmer(Reaction~Days+(Days|Subject),data=sleepstudy0,
        control=lmerControl(check.nobs.vs.nRE="ignore"))
## warning messages

      

The estimated deviations differ from the estimated values lme

, but this is not surprising as some of the parameters are not collectively identified.

If you're only interested in inference about fixed effects, it might be okay to ignore these issues, but I wouldn't recommend it.

The smart thing to do is to admit that variation among slopes is not identifiable; there may be individual variation among the slopes, but you simply cannot estimate it with this model. Do not try; random intercept models fit and let the implicit / standard random error account for variation among slopes.

There's a recent related question about CrossValidated ; there I also refer to another example .

+6


source







All Articles