[R] How to specify arguments in lme() ?

From: w jj <jiajiehere_at_hotmail.com>
Date: Thu 18 Jan 2007 - 15:25:59 GMT


Hi,

I have a question about the function lme() in R.

I have a 2*2*3 layout with some missing data (labelled as *). These 3 factors are labelled as A,B,C, the response is Score. The layout is as follows:-

A              B                 C                    Score
1               1                  1                         5
1               1                  2                         *
1               1                  3                         1
1               2                  1                         4
1               2                  2                         4
1               2                  3                         *
2               1                  1                         3
2               1                  2                         *
2               1                  3                         4
2               2                  1                         2
2               2                  2                         *
2               2                  3                         5

Suppose these data are stored in a data frame called "test".

If all these 3 factors are fixed, then I can fit a model without the 3-way interaction as:-
fit1<-lm(Score~A*B+A*C+B*C,data=test)

If one of these factors, say A, is a random effect variable, then I need to fit a mixed effect model using lme(). I have read the R documention on lme(), but I am still not clear how to specify the random argument. I tried to do:-

fit2<-lme(Score~A*B+A*C+B*C,data=test,random=~A, na.action=na.pass)

but the system give a message as follows:- Error in getGroups.data.frame(dataMix, groups) :

        Invalid formula for groups

So how should I specify the arguments?

Thank you very much for your help!

Jiajie



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 Fri Jan 19 02:43:15 2007

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 Thu 18 Jan 2007 - 17:30:26 GMT.

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