[R] repeated measures ANOVA

Ioannis Dimakos idimakos at upatras.gr
Mon Feb 27 22:41:55 CET 2006


Christian,

One thing that may help with the data you provide is to make sure that
group, time, and subject are indeed factors.
group <- factor(group)
time <- factor(time)
subject <- factor(subject)

Running your analyses in both SPSS 13.0 and R.2.2.1 (the R sessions were
ran in win xp and ubuntu/linux), gave the following results:

1) SPSS
time: F(2,16) = 7.623,p <.005.

2) When I ran your code, the aov piece gave a singularity warning, while the
lmer bit gave a false convergence message.

I believe that in your case, the code should be:

aov(p.pa~time*group + Error(subject))
or
aov(p.pa~time*group + Error(subject + subject:time)

They both give identical results

When following the "nlme way", your code is correct and should give the
same results as in spss, or aov.

I was also stuck in the "lmer way", even when I changed the code to:
lmer(p.pa~time*group + (time|subject).


Perhaps, another list member, or Prof. Bates could provide more info on
this one?

IKD

On Mon, February 27, 2006 17:15, Christian Gold wrote:
> Dear list members:
>
> I have the following data:
> group <- rep(rep(1:2, c(5,5)), 3)
> time <- rep(1:3, rep(10,3))
> subject <- rep(1:10, 3)
> p.pa <- c(92, 44, 49, 52, 41, 34, 32, 65, 47, 58, 94, 82, 48, 60, 47,
> 46, 41, 73, 60, 69, 95, 53, 44, 66, 62, 46, 53, 73, 84, 79)
> P.PA <- data.frame(subject, group, time, p.pa)
>
> The ten subjects were randomly assigned to one of two groups and
> measured three times. (The treatment changes after the second time
> point.)
>
> Now I am trying to find out the most adequate way for an analysis of
> main effects and interaction. Most social scientists would call this
> analysis a repeated measures ANOVA, but I understand that mixed-effects
> model is a more generic term for the same analysis. I did the analysis
> in four ways (one in SPSS, three in R):
>
> 1. In SPSS I used "general linear model, repeated measures", defining a
> "within-subject factor" for the three different time points. (The data
> frame is structured differently in SPSS so that there is one line for
> each subject, and each time point is a separate variable.)
> Time was significant.
>
> 2. Analogous to what is recommended in the first chapter of Pinheiro &
> Bates' "Mixed-Effects Models" book, I used
> library(nlme)
> summary(lme ( p.pa ~ time * group, random = ~ 1 | subject))
> Here, time was NOT significant. This was surprising not only in
> comparison with the result in SPSS, but also when looking at the graph:
> interaction.plot(time, group, p.pa)
>
> 3. I then tried a code for the lme4 package, as described by Douglas
> Bates in RNews 5(1), 2005 (p. 27-30). The result was the same as in 2.
> library(lme4)
> summary(lmer ( p.pa ~ time * group + (time*group | subject), P.PA ))
>
> 4. The I also tried what Jonathan Baron suggests in his "Notes on the
> use of R for psychology experiments and questionnaires" (on CRAN):
> summary( aov ( p.pa ~ time * group + Error(subject/(time * group)) ) )
> This gives me yet another result.
>
> So I am confused. Which one should I use?
>
> Thanks
>
> Christian
>
>
>
>
> --
> ____________________________
> Dr. Christian Gold, PhD
> http://www.hisf.no/~chrisgol
>
> ______________________________________________
> 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
>


-- 
Ioannis C. Dimakos, Ph.D.
University of Patras
Department of Elementary Education
Patras, GR-26500 GREECE
http://www.elemedu.upatras.gr/dimakos/
http://yannishome.port5.com/

-- 
Ioannis C. Dimakos, Ph.D.
University of Patras
Department of Elementary Education
Patras, GR-26500 GREECE
http://www.elemedu.upatras.gr/dimakos/
http://yannishome.port5.com/




More information about the R-help mailing list