[R-sig-ME] Multivariate Multilevel Model with lmer()

Douglas Bates bates at stat.wisc.edu
Tue Mar 22 18:56:25 CET 2011


On Fri, Feb 4, 2011 at 9:56 AM, Christopher T. Moore <moor0554 at umn.edu> wrote:
> Hello,

> I'm trying to use lmer() to replicate Snijders and Bosker's multivariate
> multilevel model examples 13.1 and 13.2, which they estimated with MLwiN.
> My code (see below) replicates the fixed effects and between-schools
> variance estimates in the book, but not the within-schools variances.

> I think I need to suppress the residual variance estimate so that level 1
> defines the multivariate structure and the level 2 variances become the
> residual between-pupil variances. Is that possible with lmer()? Any such
> options in the nlme package?

As mentioned on this list a short time ago, there is no option in lmer
to suppress the residual variance estimate.  The internal
representation of the model involves solving a penalized least squares
problem and there is no obvious way of suppressing the residuals.

> I searched the help files and the R-help archives but couldn't find a
> solution. Thanks in advance.
>
> Regards,
> Chris
>
> --
> Christopher T. Moore, M.P.P.
> Doctoral Student
> Quantitative Methods in Education
> University of Minnesota
> 44.9785°N, 93.2396°W
> moor0554 at umn.edu
> http://umn.edu/~moor0554
>
>
> ####################
> #Attempt to reproduce Snijders and Bosker's examples 13.1 and 13.2
> library(lme4)
> library(reshape)
> download.file("http://www.ats.ucla.edu/stat/mplus/examples/ma_snijders/mlbook1.dat",
> destfile="mlbook1.dat")
> data.mlbook1 <- read.csv("mlbook1.dat")
> names(data.mlbook1) <- c("schoolNR", "pupilNR", "IQ_verb", "IQ_perf",
> "sex", "Minority", "repeatgr", "aritPRET", "classNR", "aritPOST",
> "langPRET", "langPOST", "ses", "denomina", "schoolSES", "satiprin",
> "natitest", "meetings", "currmeet", "mixedgra", "percmino", "aritdiff",
> "homework", "classsiz", "groupsiz")
> data.mlbook1$IQ_verb <- scale(data.mlbook1$IQ_verb, scale=F)
> data.mlbook1$groupsiz <- scale(data.mlbook1$groupsiz, scale=F)
> data.mlbook1$schoolNR <- factor(data.mlbook1$schoolNR)
> data.mlbook1$pupilNR <- factor(data.mlbook1$pupilNR)
> data.mlbook1 <- ddply(data.mlbook1, "schoolNR", transform,
> schIQV=mean(IQ_verb))
> data.mlbook1 <- melt(data.mlbook1, measure.vars=c("aritPOST", "langPOST"))
> str(data.mlbook1)
> model.empty <- lmer(value ~ - 1 + variable +
>  (- 1 + variable | schoolNR / pupilNR), data.mlbook1, REML=F)
> print(model.empty, correlation=F)
> model.full <- lmer(value ~ - 1 +
>  variable * IQ_verb - IQ_verb +
>  variable * schIQV - schIQV +
>  variable * groupsiz - groupsiz +
>  variable * I(IQ_verb * groupsiz) - I(IQ_verb * groupsiz) +
>  (- 1 + variable | schoolNR / pupilNR), data.mlbook1, REML=F)
> print(model.full, correlation=F)
> ####################
>
> _______________________________________________
> R-sig-mixed-models at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>




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