[R] syntax of nlme
Thomas Wutzler
twutz at bgc-jena.mpg.de
Mon Oct 9 18:06:34 CEST 2006
Dear Douglas Bates and Spencer Graves,
thank you for your replies.
In the meantime I got the book and will recommend it to my colleages :)
I learned the answer to my problem and want to post it here:
If you use ungrouped data (a plain dataframe) you must specifiy the
grouping variable in the random argument behind "|"
The fixed argument is used to distuingish coefficients from data inputs.
In its simple form, it is not a list (as in nls), but a formula with all
coefficients seperated by + on the left side and ~ 1 as right hand side
(other forms allow e.g. including additional covariates)
The random argument is used to specify those coefficients that have a
random effect associated.
Again (in its simple form) it is not a list but a formula with all
coefficients on the left side seperated by + on the left side and ~ 1 on
the right side (other forms allow nested effects, different correlation
matrices, etc.)
The grouping variable is specified on the far right behind "|".
My previous example does not make sense, because there are no
repetitions for the runs, so I switch to the Loblolly example of the
online help.
In online-help-examples, the grouping variable is not specified in the
call to lme, because it is already specified in the grouped data (see
?groupedData). In the online help example, "Seed" is the grouping factor.
I did not understand the online help first, because the grouping
variable was not specified with the call to nlme.
the example specifies the call:
fm1 <- nlme(height ~ SSasymp(age, Asym, R0, lrc),
data = Loblolly,
fixed = Asym + R0 + lrc ~ 1,
random = Asym ~ 1,
start = c(Asym = 103, R0 = -8.5, lrc = -3.3))
without grouped data (athough I recommend using grouped data after
reading the book), the call can be formulated as:
l2 <- data.frame( height=Loblolly$height, age=Loblolly$age,
Seed=Loblolly$Seed)
fm2 <- nlme(height ~ Asym+(R0-Asym)*exp(-exp(lrc)*age)
,data = l2
,fixed = Asym + R0 + lrc ~ 1
,random = Asym ~ 1 | Seed
,start = c(Asym = 103, R0 = -8.5, lrc = -3.3)
)
Thanks,
Thomas
More information about the R-help
mailing list