From: Doran, Harold <HDoran_at_air.org>

Date: Wed 26 Jul 2006 - 08:51:34 EST

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.

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. Received on Wed Jul 26 08:55:47 2006

Date: Wed 26 Jul 2006 - 08:51:34 EST

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]]

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. Received on Wed Jul 26 08:55:47 2006

Archive maintained by Robert King, hosted by
the discipline of
statistics at the
University of Newcastle,
Australia.

Archive generated by hypermail 2.1.8, at Wed 26 Jul 2006 - 11:19:46 EST.

*
Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help.
Please read the posting
guide before posting to the list.
*