Re: [R] A question on the library lme4

From: Douglas Bates <>
Date: Sun 24 Apr 2005 - 23:39:51 EST

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. mailing list PLEASE do read the posting guide! Received on Sun Apr 24 23:46:31 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:31:25 EST