[R] use of random and nested factors in lme

Kingsford Jones kingsfordjones at gmail.com
Tue Apr 6 03:14:09 CEST 2010


On Mon, Apr 5, 2010 at 12:21 PM, Joris Meys <jorismeys at gmail.com> wrote:
> Dear all,
>
> I've read numerous posts about the random and nested factors in lme,
> comparison to proc Mixed in SAS, and so on, but I'm still a bit confused by
> the notations. More specifically, say we have a model with a fixed effect F,
> a random effect R and another one N which is nested in R.
>
> Say the model is described by Y~F
> Can anyone clarify the difference between :
> random = ~1|R:N

Here you ask to estimate the variance in random intercepts between
levels created by the interaction of the R and N factors (note
anything on the RHS of the "|" must be factor (or can be converted)
since this specifies the groups between which the random effects vary)

> random = ~1|R/N

The RHS can be read as "R and N %in% R".  So this is as above, but
additionally estimate the variance in random intercepts between the
levels of R.

> random = ~R:N
> random = ~R/N

In the above formulas you need to specify which effects you're
interested in; as is they only specify grouping.

> random = ~R|N

Because the intercept is implicit unless explicitly removed (with +0
or -1), this requests estimation of the variance in random intercepts
between levels of N, as well as either variance in random slopes
between levels of N if R is numeric, or variation in random effects
associated with levels of the R factor between levels of N if R is a
factor (resulting in as many variance components being estimated as
there are levels of R).  Note that as with factor-level effects in the
fixed portion of the model, what is being estimated will depend on the
contrast coding for the R factor.  Also, with factor random effects
specifications it is often sensible to remove the intercept (e.g., ~0
+ R|N) to estimate random variation associated with a specific level
rather than variation in, e.g., difference from a baseline level.  The
interactions between contrast coding, mean structure and in/exclusion
of intercepts is too much to go into here, but hopefully this gives
the gist of concepts.

> random = ~1|R+N
>
> or direct me to an overview regarding notation of these formulas in lme
> (package nlme)? The help files weren't exactly clear to me on this subject.

IMO Pinheiro and Bates' companion book to nlme is a prerequisite for
efficient use of their software.

hoping this helps,

Kingsford Jones

>
> What confuses me most, is the use of the intercept in the random factor.
> Does this mean the intercept is seen as random, has a random component or is
> it just notation? In different mails from this list I found different
> explanations.
>
> Thank you in advance.
> Cheers
> Joris
>
> --
> Joris Meys
> Statistical Consultant
>
> Ghent University
> Faculty of Bioscience Engineering
> Department of Applied mathematics, biometrics and process control
>
> Coupure Links 653
> B-9000 Gent
>
> tel : +32 9 264 59 87
> Joris.Meys at Ugent.be
> -------------------------------
> Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list