[R-sig-ME] Multivariate Multilevel Model with lmer()
Christopher T. Moore
moor0554 at umn.edu
Fri Feb 4 17:27:29 CET 2011
P.S. Here's a related post:
https://stat.ethz.ch/pipermail/r-sig-mixed-models/2011q1/005059.html
--
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
On Feb 4 2011, Christopher T. Moore 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?
>
>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)
>####################
>
>
More information about the R-sig-mixed-models
mailing list