[R] Syntax in lmer...

ONKELINX, Thierry Thierry.ONKELINX at inbo.be
Mon Mar 23 10:19:16 CET 2009

Dear Anne,

Is age a continuous or a categorical variable? If it is a continuous
variable, then I would add it to the fixed effects.

You have two options for the random effect: (Fertilier|Family/Species)
or (1|Family/Species) + (0 + Fertilizer|Family/Species). Both yield a
random intercept and a random slope along Fertilizer. But the main
difference is the correlation between the random effects. The first
model allows for correlation between the random effect and the random
slope. Whereas the second model implies that they are independent.

This is what I would do to test for the interaction.
#If age is categorical
M0 <- lmer(RGR ~ Fertilizer * Status + (1|Age) + (1|Family/Species) + (0
+ Fertilizer|Family/Species), data=rgr, REML =  TRUE)
M1 <- lmer(RGR ~ Fertilizer * Status + (1|Age) + (1|Family/Species),
data=rgr, REML =  TRUE)
anova(M0, M1)

#If age is continuous
M0 <- lmer(RGR ~ Fertilizer * Status + Age + (1|Family/Species) + (0 +
Fertilizer|Family/Species), data=rgr, REML =  TRUE)
M1 <- lmer(RGR ~ Fertilizer * Status + Age + (1|Family/Species),
data=rgr, REML =  TRUE)
anova(M0, M1)



PS. The R-Sig-mixed models mailing list is better suited for questions
on lme4.

ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
tel. + 32 54/436 185
Thierry.Onkelinx at inbo.be 

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ Roger Brinner

The combination of some data and an aching desire for an answer does not
ensure that a reasonable answer can be extracted from a given body of
~ John Tukey

-----Oorspronkelijk bericht-----
Van: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
Namens Anne Kempel
Verzonden: maandag 23 maart 2009 9:54
Aan: r-help at r-project.org
Onderwerp: [R] Syntax in lmer...

Sorry for bothering you - but I have a little problem. I`m completely 
new in R and trying to use lmer. That works, but I m not sure if my code

is right, so I would just like to get an opinion from the experts.

I have a Growthrate of plants (RGR
Fixed Factors: Fertilizer, Status (alien or native plants) and their 
Random Factors: Age is a covariable; than I have plantfamily and Species

nested within Family.
Now I want also to test for the interaction of Fertilizer with 
plantfamily and species. Did I do this the right way, and is the 0+ 


I`m thankful for any comments!

Anne Kempel
Institute of Plant Sciences
University of Bern
Altenbergrain 21
CH-3103 Bern
kempel at ips.unibe.ch

R-help at r-project.org mailing list
PLEASE do read the posting guide
and provide commented, minimal, self-contained, reproducible code.

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer 
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in  this message 
and any annex are purely those of the writer and may not be regarded as stating 
an official position of INBO, as long as the message is not confirmed by a duly 
signed document.

More information about the R-help mailing list