[R] Multiple random effects in lme?

Anon. bob.ohara at helsinki.fi
Mon Sep 16 11:56:32 CEST 2002


Thanks to the people who replied to my quesry (my original message is
below).  It appears I'm not the only one to have had this problem, so
I'vwe taken the liberty of posting a summary.  Here they are:

>From In-Sun Nam:
You can use a crossed random effects structure; if that is the one that
you
are trying to say.
The syntax will be
random = pdBlocked(list(pdSymm(~Pop-1), pdSymm(~Tree-1)))
so that your random effect structure is represented by a block diagonal
variance-covariance matrix where diagonal blocks given by multiples of
general positive-definite matrices.

I think that -1 will be necessary as you would not like to have
intercept
values; otherwise you can take them out.

>From Rich Raubertas:
Check the archives for posts by Doug Bates on 21 Feb 2002 and 
18 Jul 2001.  He describes how to code non-nested random 
effects in lme.

To which I add:
The 21/2/02 message is at
<http://maths.newcastle.edu.au/~rking/R/help/02a/1399.html>, and is
answering what is essentially the same question.  Part of it is:

The answer to your question is not "extremely simple". It happens 
that the lme function is much better suited to nested random effects 
than to crossed random effects. To estimate crossed random effects 
you must create an awkward formulation with a grouping factor that has 
one level and the random effects model matrix based on the indicators 
for factor a and the indicators for factor b. These two sets of 
random effects each have variance-covariance matrices that are 
multiples of an identity and the are grouped together as a 
block-diagonal matrix. The whole formulation is 

 lme(response ~ 1, data = myData, 
     random = pdBlocked(list(pdIdent(~ a - 1), pdIdent(~ b - 1)))) 

and myData must be a groupedData object with a grouping factor that 
has only one level. 

This is followed by a worked example.  The other message gives pretty
much the same information.  

The difference between the two suggestions is that one uses pdSymm, and
the other uses pdIdent.  I assume they end up with the same answer -
I'll have to check later.

Anyway, many thanks for the responses, as always.  There is now another
message with the solution in the archives.

Bob

-- 
Bob O'Hara

Rolf Nevanlinna Institute
P.O. Box 4 (Yliopistonkatu 5)
FIN-00014 University of Helsinki
Finland

tel: +358 9 191 23743      mobile: +358 50 599 0540
fax: +358 9 191 22779    email: bob.ohara at helsinki.fi

It is being said of a certain poet, that though he tortures the English
language, he has still never yet succeeded in forcing it to reveal his
meaning
- Beachcomber



"Anon." wrote:
> 
> Moi!
> 
> I was helping to teach a course on mixed models this week, and we came
> across a problem with coding more than one random effect in lme when
> they aren't nested.
> 
> As an example, suppose we have an experiment where we sample moths from
> several populations, and place the moths on different trees, and measure
> a trait (in this case survival of offspring, but that's less
> important).  We want to treat Population and Tree as random effects, as
> that will tell us something about adaptation.  Naively, i would expect
> to code the data in lme as something like:
> 
> lme(x ~ 1, random=~1|(Pop + Tree))
> 
> but this doesn't work, and I can't work see what to do (or where to look
> to find out!).  Can anyone point me in the right direction?
> 
> Thanks in advance.
> 
> Bob
> 
> --
> Bob O'Hara
> 
> Rolf Nevanlinna Institute
> P.O. Box 4 (Yliopistonkatu 5)
> FIN-00014 University of Helsinki
> Finland
> Telephone: +358-9-191 23743
> Mobile: +358 50 599 0540
> Fax:  +358-9-191 22 779
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
> Send "info", "help", or "[un]subscribe"
> (in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list