[R] Possible bug in lmer nested analysis with factors
Doran, Harold
HDoran at air.org
Fri Sep 16 20:19:42 CEST 2005
Doug Bates has the following article in R News. To date, it is the only
source I know of documenting the lmer function.
@Article{Rnews:Bates:2005,
author = {Douglas Bates},
title = {Fitting Linear Mixed Models in {R}},
journal = {R News},
year = 2005,
volume = 5,
number = 1,
pages = {27--30},
month = {May},
url = {http://CRAN.R-project.org/doc/Rnews/},
}
-----Original Message-----
From: r-help-bounces at stat.math.ethz.ch
[mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Yan Wong
Sent: Friday, September 16, 2005 1:58 PM
To: R-help
Subject: Re: [R] Possible bug in lmer nested analysis with factors
On 16 Sep 2005, at 17:12, Doran, Harold wrote:
> I think you might have confused lme code with lmer code. Why do you
> have c/d in the random portion?
Apologies. I obviously have done something of the sort. I assumed that
the 'random' assignment in lme could just be incorporated into an lmer
call by placing it in brackets and removing the ~, so that
lme(a ~ b, random= ~ 1|c/d)
would be equivalent to
lmer(a ~ b + (1|c/d))
Is there a good guide somewhere to lmer calling conventions? I obviously
don't understand them. As you can see, I would like to nest d within c,
(and actually, c is nested in b too).
Perhaps it would be better with some explanation of the Crawley data.
There are 3 fixed drug treatments ('b') given to 2 rats (6 rats in
all: 'c'), and 3 samples ('d') are taken from each of the rat's livers,
with some response variable recorded for each sample ('a':
here just allocated a Normal distribution for testing purposes). I.e.
c and d are random effects, with d %in% c and c %in% b.
He analyses it via
aov(a ~ b+c+d+Error(a/b/c))
I'm wondering what the lme and lmer equivalents are. I've been told that
a reasonable form of analysis using lme is
a<-rnorm(36);b<-rep(1:3,each=12);d<-rep(1:3,each=2,6)
c <- rep(1:6, each=6) #use unique labels for each rat ## I got this
wrong in my previous example
model1 <- lme(a ~ b, random= ~ 1|c/d)
Which gives what looks to be a reasonable output (but I'm new to all
this mixed modelling stuff). How would I code the same thing using lmer?
> I think what you want is
>
>> lmer(a ~ b + (1 | c)+(1|d))
>>
>
> Which gives the following using your data
I'm not sure this is what I wanted to do. But thanks for the all the
help.
Yan
______________________________________________
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
More information about the R-help
mailing list