Nantachai

It seems as though you have created the model matrices from the matrix representation of the model. This is unecessary as lme will construct those for you from your data frame.

The first thing I recommend you do is use lmer instead of lme. Second, you should look in the vignette in the mlmRev package for examples of how to use this function.

vignette('mlmSoftRev')
or use
example(lmer)

Experiment with these examples and look at the dataframes used so you can see how the data are organized. Then, apply what you see to your particular data set. After that, you might be able to come back to the list with a more specific question where you will get plenty of advice.

To get the most help from the list, it is best to give a very clear, replicable example. 

Harold



-----Original Message-----
From: r-help-bounces@stat.math.ethz.ch on behalf of Nantachai Kantanantha
Sent: Tue 7/25/2006 5:44 PM
To: r-help@stat.math.ethz.ch
Subject: [R] how to fit with "lme" function
 
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

______________________________________________
R-help@stat.math.ethz.ch 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.


	[[alternative HTML version deleted]]

