[R-sig-ME] question about linear mixed models
JOSE A ALEMAN
aleman at fordham.edu
Thu Jul 8 18:12:49 CEST 2010
Ok, so now I'm slightly confused, because I tried (1 |nation/year) and nmle
returned the exact same results that lme4 returns when you use the syntax
(1 | nation) + (1 | year). I thought was I was trying to estimate was cross
random effects, not nested random effects. To be more precise, the model I
want to estimate looks like this:
(Embedded image moved to file: pic08452.jpg),
where the terms (Embedded image moved to file: pic12342.jpg) and (Embedded
image moved to file: pic08045.jpg) are varying-intercept parameters for
units and time.
Yet the output is identical...
Thanks,
Jose
Andrew Dolman
<andydolman at gmail
.com> To
JOSE A ALEMAN <aleman at fordham.edu>
07/08/2010 03:56 cc
AM r-sig-mixed-models at r-project.org
Subject
Re: [R-sig-ME] question about
linear mixed models
Hello Jose,
lme4 can handle crossed and nested random effects whereas nlme can
only do nested random effects.
What you've specified here:
> mixed.model <- lmer (y ~ x1+x2+x3 + (1 | nation) + (1 | year), data=data)
has crossed random effects.
> and R returns the following output for the random effects:
>
> Random effects:
> Groups Name Variance Std.Dev.
> year (Intercept) 0.00 0.00
> nation (Intercept) 9.40 3.07
> Residual 2.42 1.56
and you seem to have zero variance associated with the random effect
"year". This may be a problem with the way you've coded your data
which is why it's helpful if you post a sample of your data, or dummy
data, with your question.
do > head(mydataframe)
the output from str (mydataframe) is useful too because we can see how
many levels of each factor you have
If you want a nested model in lme4 you should specify it as + (1 |
nation/year) OR +(1|nation) + (1|nation:year)
I'm not sure what the model is that you specified in nlme but it can't
be the same as the one for lme4 because nlme cannot do crossed random
effects
> mixed.effects <- lme (y ~ x1+x2+x3, data=data,
> random=~1|nation+1|year, method="REML")
Andy.
More information about the R-sig-mixed-models
mailing list