Skip to content
Back to formatted view

Raw Message

Message-ID: <426BA1A7.3030203@stat.wisc.edu>
Date: 2005-04-24T13:39:51Z
From: Douglas Bates
Subject: A question on the library lme4
In-Reply-To: <Pine.LNX.4.44.0504232113160.20985-100000@strix.ciens.ucv.ve>

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.