[R] fitting a linear mixed effects model

Peter Dalgaard BSA p.dalgaard at biostat.ku.dk
Tue Sep 17 18:18:24 CEST 2002


"E. Corda" <e.corda at oncfs.gouv.fr> writes:

> Dear all,
> 
> I still have the same question as before. You'll find below my original
> question and Peter's answer, as well as additional elements.
> 
> A 17:14 11/09/02 +0200, vous avez écrit :
> >"E. Corda" <e.corda at oncfs.gouv.fr> writes:
> >
> >> fm1fox <- lme(nbfox ~ zone*annee, data=fox, random ~ 1|transect/year)
> >> 
> >> I would like the TRANSECT factor to be nested in the ZONE factor. But
> >> if I estimate the model like this:
> >> 
> >> fm1fox <- lme(nbfox ~ zone*annee, data=fox, random ~
> >> 1|zone/transect/year)
> >
> >(shouldn't that be transect/zone/year?)
> 
> No, one zone has several transects so TRANSECT is nested within ZONE.

Sorry, I think I got the order confused by seeing year appearing last
(i.e. you really mean that year is nested within the others with no
effect of the same year in different places?)


> 
> >
> >> zone is now a random effect.
> >> 
> >> Do you have any idea on this? Thanks a lot for any help.
> >
> >Does random ~ 1|(zone:transect)/year work? Otherwise, you might need
> >something like random ~ 1|interaction(zone,transect)/year.

> The two commands indicated by Peter don't work on R. Moreover, I don't want
> to estimate a model with ZONE*TRANSECT interaction, I'd rather want to
> specify that the between transects variability must be taken into account
> within each zone. The problem is that the way we write the model in lme
> makes random effects be separated from fixed effects. So I can't see how I
> could write the model I want. 
> 
> Thanks very much for any help,

You may need to spell it out a bit more, but I contend that you *do*
want the interaction term. It's the main effects that you don't want,
so how about creating a random effect for each combination of zone and
transect like this:

z.by.t <- interaction(zone,transect)

lme(....,random=~ 1|z.by.t/year)

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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