[R-sig-ME] fitted/resid method for lme4a does not work correctly with na.action

gregor.hochschild at gmx.de gregor.hochschild at gmx.de
Wed Nov 23 13:26:50 CET 2011


Hi, I working with lme4a right now (thanks for the help for my earlier question) and realized that the merMod class does behave as other fitted objects when using fitted and resid with na.action (I actually think that merMod does not has a residuals method. Only the respModule object has one but merMod should work with resid).
When the option 'na.action=na.exclude' is used, fitted and resid should return a full length vector with missing values. lme4 does but lme4a does not. 

Greg


Here is an example:

# data
y=rnorm(100)
x=rep(1:10,10)
group=rbinom(100,1,0.5)
x[sample(1:100,10)]=NA

# lme4
m1=lme4::lmer(y~x+(1|group))
length(fitted(m1))
m1=lme4::lmer(y~x+(1|group),na.action=na.exclude)
length(fitted(m1))

# lme4a
m1=lmer(y~x+(1|group))
length(fitted(m1))
m1=lmer(y~x+(1|group),na.action=na.exclude)
length(fitted(m1))
--




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