[R] lme: Specifying a formula
Douglas Bates
bates at stat.wisc.edu
Fri Aug 17 21:18:43 CEST 2001
Christian Hennig <fm3a004 at math.uni-hamburg.de> writes:
> I am faced with the following model:
>
> y=E+P+M+H+PxE+Error
>
> y is a response, E and P are factors with fixed effects.
> M is a random effect nested in P and H is a random effect nested in M.
> PxE is interaction of P and E.
>
> It seems that I should fit such a model with the lme function of library
> nlme, but I was not able to figure out from the help page how to specify the
> formula. In the nlme documentation, the term "nested" is always associated
> with a "grouping", and I do not know what my grouping is here.
For a complicated model like this you may find it worthwhile looking
at the examples in
@Book{pinh:bate:2000,
author = {Jos\'{e} C. Pinheiro and Douglas M. Bates},
title = {Mixed-Effects Models in \textsf{S} and \textsf{S-PLUS}},
publisher = {Springer},
year = 2000,
series = {Statistics and Computing}
}
The grouping refers to the groups in the data with which random
effects are associated. If the levels of the M factor are distinct
for different levels of P then you can fit your model as
lme(y ~ E * P, data = mydata, random = ~ 1 | M/H)
The last argument indicates that there will be an additive scalar
random effect for M and for H within M.
If you do not have distinct levels for M within P you can create a new
factor with
getGroups(~ 1 | P/M, data = mydata, level = 2)
and assign it as the grouping factor.
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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