[R] Partially crossed and nested random factors in lme/lmer

Corsin Müller , Zoologisches Inst. corsin.mueller at zool.unizh.ch
Sat Apr 22 16:22:48 CEST 2006


Hi all,

I am not a very proficient R-user yet, so I hope I am not wasting people’s 
time. I want to run a linear mixed model with 3 random factors (A, B, C) 
where A and B are partially crossed and C is nested within B. I understand 
that this is not easily possible using lme but it might be using lmer. I 
encountered two problems when trying:

Firstly, I can enter two random factors in lmer but I do not get complete 
outputs using both anova () and summary (). For instance, I only get df, SS, 
and MS using anova(). Even so the model runs without giving an error 
message.

> lmer.inspection <- lmer(duration.root.transf~sex*sample.sex+age+sample.age+sample.type+first.bout+location+sample.source + (1|acceptor.grp) + (1|donor.grp))
> anova (lmer.inspection)
Analysis of Variance Table
                Df  Sum Sq Mean Sq
sex             1 0.06653 0.06653
sample.sex      1 0.60389 0.60389



Running the same model in lme using only one random factor works fine.

> lme.inspection <- lme(duration.root.transf~sex*sample.sex+age+sample.age+sample.type+first.bout+location+sample.source, random=~1|acceptor.grp)
> anova (lme.inspection)
                numDF denDF  F-value p-value
(Intercept)        1  4427 47690.12  <.0001
sex                1  4427     7.93  0.0049
sample.sex         1  4427    65.71  <.0001



Running the example given  in “?lmer” also does not give a complete anova 
table. However, the example discussed in the email by Jacob Michaelson on 
the 24th of April 2005 “[R] random interactions in lme” gives a complete 
output. So I seem to miss out on something.

Secondly, I am at a loss with how I can enter the third random factor, which 
should be nested within acceptor.grp. When trying the to me intuitively 
sensible

> lmer.inspection <- lmer(duration.root.transf~ 
 + (1|acceptor.grp/id) + (1|donor.grp))

the program terminates

I am grateful for any suggestions.

Version used: R 2.2.1 for Windows

Thanks,
Corsin Mueller

________________________________________

Corsin Mueller
Universität of Zuerich
Zoological Institute
Winterthurerstr. 190
8057 Zuerich
Switzerland

fon +41-(0)44-63 55277
fax +41-(0)44-63 55490
email corsin at zool.unizh.ch




More information about the R-help mailing list