Hi Ryan
Your model code suggests that Type is a variable that you have in your FREE data
frame, but you don't mention it, that is probably part of your problem?
The second question is how are your data structured? Sex goes in the fixed part
of the model. Swimmer is almost certainly goes in the random component, as you
have identified. The question is what to do with Swim. This could either be the
key variable of interest or simply a label representing replicates. What is the
hypothesis you're trying to test? When swimmers 1..n undertake swim 1 is
this all at the same time? If this is the case, do you have reason to believe
that there could be some similarlites (not sure what, maybe temperature, wind
conditions, fatigue) between swimmers on the same swim?
Without information on the data structure then its difficult to suggest anything
further. As a first guess you could try comparing:
m1 <- lme(Difference~Sex, random=~1|Swimmer, data=FREE)
m2 <- lme(Difference~Sex, random=~1|Swimmer/Swim, data=FREE)
With Swim in the fixed component of the model you're suggesting a linear
relationship between Difference and Swim, are you sure this is what you want? If
you really think Swim should be in the fixed compoent then you might want to
compare:
m3 <- lme(Difference~Sex*Swim, random=~1|Swimmer, data=FREE)
m4 <- lme(Difference~Sex*Swim, random=~Swim|Swimmer, data=FREE)
The latter will fit an overall relationship between Difference and Swim, and
then estimate both intercept and slope random effects for Swim.
regards
Mike D
>>> <readams at colby.edu> 19/12/2006 03:18 >>>
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
______________________________________________
R-help at 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.
--
This message (and any attachments) is for the recipient only...{{dropped}}