On Feb 13, 2008 9:53 AM, Ista Zahn <istazahn at gmail.com>
wrote:> Dear R listers,
> I know I'm breaking the rules by asking a "homework" related
question--
> I hope you'll forgive me. I am a social psychology graduate student,
> and the only one in my department who uses R. I successfully completed
> my multiple regression and structural equation modeling courses using
> R (John Fox's car and sem packages were a big help, as was his book).
> Now I am taking a hierarchical linear modeling course, and am hoping
> that I can use R for this also.
I think that learning to use R for a course that is based on other
software doesn't fall within the "no homework questions" rule.
> I've searched the list archives, and
> consulted the one-line version of Pinheiro and Bates (available
> through my library), but I'm having a great deal of difficulty
> translating what I'm learning in class into lmer syntax.
Wow! A one-line version! I'd like to read that. Must be a really long line.
> Specifically,
> the instructor is using HLM 6.0. In this program, one specifies the
> level one and level two models explicitly, and I'm having trouble
> understanding what the equivalent of this is in lmer. Most of the
> examples we cover in class are change models, i.e., we working with
> longitudinal data.
>
> Specific questions:
>
> in HLM 6.0, we build the following model;
>
> Y = P0 + P1*(CONFLICT) + P2*(TIMEYRS) + E
> Level-2 Model
> P0 = B00 + B01*(H0MCITOT) + R0
> P1 = B10 + B11*(H0MCITOT) + R1
> P2 = B20 + B21*(H0MCITOT) + R2
What determines the level 2 groups? I don't see it in the
specification although I will admit that I have difficulty reading
those specifications. To me they confound fixed effects and random
effects and end up expressing fixed-effects interactions in obscure
and confusing ways.
The way I have to understand this is to substitute the P0, P1 and P2
into the first equation, expand the terms then collect the fixed
effects and the random effects. That would give me
Y = B00 + B01*(H0MCITOT) + B10*(CONFLICT) + B11*(CONFLICT)*(H0MCITOT)
+ B20*(TIMEYRS) + B21*(TIMEYRS)*(H0MCITOT) + R0 + R1*(CONFLICT) +
R2*(TIMEYRS) + E
To me the specification is not complete because I don't know what
groups the random effects R0, R1 and R2 are associated with. Also,
are R0, R1 and R2 allowed to be correlated within groups or are they
required to be independent?
Let's say that GRP is the variable that defines the groups that share
a common level of the random effects. Then the uncorrelated random
effects model is written
Y ~ CONFLICT*H0MCITOT + TIMEYRS*H0MCITOT + (1|GRP) + (CONFLICT-1|GRP)
+ (TIMEYRS-1|GRP)
and the model with correlated random effects is
Y ~ CONFLICT*H0MCITOT + TIMEYRS*H0MCITOT + (1+CONFLICT+TIMEYRS|GRP)
> Can someone explain to me how to represent this in lmer syntax? I've
> tried e.g.,
>
> lmer(MAT ~ 1 + CONFLICT + TIMEYRS + (1 + CONFLICT +
> + TIMEYRS | H0MCITOT))
>
> But I don't get the same result.
> More generally: Should I be using the lme4 package, the nlme package,
> or something else entirely? Is there any documentation for the lme4
> package that is geared more towards novice users?
To me the answer to the first question is to use lme4 except that the
answer to the second question is that there isn't documentation geared
to novice users. To a large degree that is my fault because I keep
changing the package so that previously written introductory
documentation is no longer applicable.
The lmer function should be faster and more reliable than lme. It
allows for fitting generalized linear mixed models and for fitting
models with crossed random effects (as in having random effects for
"subject" and for "item") or partially crossed random
effects (e.g.
longitudinal data indexed by students and teachers within schools
where students get exposed to different teachers and may move between
schools). It can handle very large data sets - I showed an example of
the analysis of 1.6 million grade point scores for 55,000 students,
8,000 instructors and 100 departments in a message to the MULTILEVEL
listserv.> Sorry for the long post, and thanks in advance for any help you can
> offer.
>
> --Ista
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>