[R-sig-ME] Mixed Effect Repeated Measures Model
Douglas Bates
bates at stat.wisc.edu
Fri Mar 11 20:40:09 CET 2011
On Thu, Feb 24, 2011 at 6:46 AM, Quincy Elamore <qelmore1 at yahoo.com> wrote:
> I have a data set in which I want to do a generalized linear model with repeated
> measures. A sample of my data is below. I'm not sure which is the correct way
> to do repeated measures in R. These are the two ways that I have it.
> study.lm<-lmer(error~true_percentage + Distance + Angle +(1|Subject),
> data=study)
> summary(study.lm)
> study.aov<- aov(log.error ~ factor(true_percentage)* factor(Distance)*
> factor(Angle) + Error(1|Subject),data=study)
> summary(study.aov)
That model specification is incorrect. The Error term takes the name
of the variable, as in "Error(Subject)".
> In the aov do I need to factor the variables?
It's a very different model from what you are fitting with lmer. In
the lmer model you are fitting a linear trend in the values of
true_percentage and of Distance and of Angle, at a total cost of 3
fixed-effects coefficients. In the aov model you are fitting many,
many more coefficients because there will be k-1 coefficients for a
factor with k levels. You say true_percentage had 5 levels, Distance
had 3 levels (25, 35 and 45) and Angle had 4 levels (25, 45, 70 and
180). The total number of coefficients estimated will be 1 + 4 * 2 *
3 or 25.
> What is the meaning of
> (1|Subject) is it telling R that each subject did all combinations of the
> trials. Is it reading all of subject 1 trials, then all of subject 2 trials,
> etc ?
I don't think it would be easy to explain the distinction between
these models in an email message. There is a lot going on here and
you may need to consult with a local statistician or resign yourself
to reading a lot of technical material.
> Each subject did 60 trials and each and I have 10 subjects. The independent
> variables are true percentages (5), distance (3), and angle (4). The predictor
> variable is error.
>
> Thank you in Advance
>
>
> Subject true_percentage Distance Angle error
> 1 60 25 180 3.33985
> 1 45 35 45 4.912889
> 1 45 35 70 4.651052
> 1 30 35 180 4.330917
> 1 15 45 25 5.134426
> 1 30 35 45 4.330917
> 1 45 35 180 4.651052
> 1 45 45 25 2.357552
> 2 60 25 180 4.330917
> 2 45 35 45 4.912889
> 2 45 35 70 3.918863
> 2 30 35 180 4.330917
> 2 15 45 25 5.326429
> 2 30 35 45 3.918863
> 2 45 35 180 4.098032
> 2 45 45 25 4.179909
> 2 30 25 25 3.33985
>
>
>
>
> [[alternative HTML version deleted]]
>
>
> _______________________________________________
> R-sig-mixed-models at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>
>
More information about the R-sig-mixed-models
mailing list