[R] how to fit with "lme" function
Nantachai Kantanantha
kantanantha at hotmail.com
Tue Jul 25 23:44:57 CEST 2006
Hi everone,
I have a question on using lme on a mixed effects model.
The linear mixed model is in the form of:
y = bX +Zu + e
where "X" and "Z" are the matrices, "b" is the coefficient vector of fixed
effects, "u" is the coefficient vector of random effects, and e is an error
vector.
I would like to use "lme" function to fit the model and estimate "b" and
"u".
However, there is an error when I call the lme function:
fit = lme(y ~ int + X1 + X2 + X3, data = data.fr, random = ~ Z1 + Z2 + Z3 +
Z4 + Z5)
where:
int is a vector of 1 in matrix X, used for the intercept term "b0",
X1, X2, X3 are columns of matrix X,
Z1 to Z5 are columns of matrix Z,
data.fr = data.frame(y,X,Z).
I got the error message:
Error in getGroups.data.frame(dataMix, groups) :
Invalid formula for groups
Could you please suggest me know to solve this problem?
Do I use incorrect arguments?
Thank you very much.
Nantachai
More information about the R-help
mailing list