[R] A question on the library lme4
Douglas Bates
bates at stat.wisc.edu
Sun Apr 24 15:39:51 CEST 2005
Luis Fernando Chaves wrote:
> Hi,
>
> I ran the following model using nlme:
>
> model2<-lme(log(malrat1)~I(year-1982),random=~1|Continent/Country,data=wbmal10)
>
> I'm trying to run a Poisson GlMM to avoid the above transformation but I
> don't know how to specify the model using lmer in the lme4 library:
>
> model3<-lmer((malrat1)~I(year-1982) + ??,data=wbmal10,family=poisson)
>
> How can I introduce a random factor of the form= ~1|Continent/Country?
It depends on whether each Country has a unique label or not. If they
have unique labels then you simply use
model3 <- lmer(malrat1 ~ I(year-1982)+(1|Country)+(1|Continent),
wbmal10, poisson)
If the Country factor is implicitly nested within Continent (e.g. the
Country labels are "1", "2", ... and on each Continent they start with
"1") then you must create a factor with unique levels by forming the
interaction of Country and Continent as Bill Venables described in his
reply.
In lmer there is no need, and indeed no way, to distinguish between
nested and non-nested grouping factors for random effects. Because of
this you cannot use implicit nesting.
More information about the R-help
mailing list