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? Thanks; -- Luis Fernando Chaves
Luis Fernando Chaves asks: : -----Original Message----- : From: r-help-bounces at stat.math.ethz.ch : [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Luis : Fernando Chaves : Sent: Sunday, 24 April 2005 11:29 AM : To: R-help at R-project.org : Subject: [R] A question on the library lme4 : : : 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) (I asked the same question of Doug Bates, as it happens.) Try the following: wbmal10 <- transform(wbmal10, Cont_Country = Continent:Country) require(lme4) model3 <- lmer(malrat1 ~ I(year - 1982) + (1|Continent) + (1|Cont_Country), family = poisson, data = wbmal10) : : How can I introduce a random factor of the form= ~1|Continent/Country? : : Thanks; : : -- : Luis Fernando Chaves : : ______________________________________________ : R-help at stat.math.ethz.ch mailing list : https://stat.ethz.ch/mailman/listinfo/r-help : PLEASE do read the posting guide! : http://www.R-project.org/posting-guide.html :
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.
Maybe Matching Threads
- trouble with extraction/interpretation of variance structure para meters from a model built using gnls and varConstPower
- problem with logLik and offsets
- predict.rma (metafor package)
- Adding regression lines to each factor on a plot when using ANCOVA
- lme anova() and model simplification