[R] Random Effects Model

readams at colby.edu readams at colby.edu
Tue Dec 19 04:18:45 CET 2006


Hello,

I am new to R, and I am trying to figure out how to use it for a  
random effects model. I am using version 2.4.0, and I also have the  
book Applied Linear Regression by Sanford Weisberg.

I have four variables: Swimmer, Sex, Swim, and Difference.  Swimmer  
identifies the number assigned to a particular person. Sex is  
male/female. Swim identifies the number swim from 1 to 6. Difference  
is my variable of interest (random).

The book says I should run something like this:

> library(nlme)
> data(FREE) #FREE is my dataset
> xyplot(Difference~Swim|Type, group=Swimmer, data=FREE,
+     panel.groups=function(x,y,...){
+       panel.linejoin(x,y,horizontal=FALSE,...)}
+     )
> m1 <- lme(Difference~Swim+Type, data=FREE, random=~1+Type|Swimmer)
> m2 <- update(m1, random=~1|Swimmer)

I've pretty much decided that xyplot doesn't work. Instead, I think  
plot will work much better.  I keep getting errors about Type. Can  
someone explain this to me? Does the code above look right?

Any kind of help will be appreciated...

Thanks in advance!

Ryan



More information about the R-help mailing list