[R-lang] Re: aov in R
João Veríssimo
jl.verissimo@gmail.com
Fri Apr 4 13:03:28 PDT 2014
Hi Zhenguang,
Your aov() command seems right to me.
I haven't tried this in SPSS, but in R, I get the same F-value (37.08),
either using t.test(), aov(), or ezANOVA(); see code below.
Maybe check your SPSS analysis to see what's going on there?
Best,
João
## Import data
MT2F1 <- read.table("./MT2-F1.txt", header=T)
str(MT2F1)
## Convert Subject to factor
MT2F1$Subject <- as.factor(MT2F1$Subject)
## Paired t-test
(myttest <- t.test(MT2F1$Average~MT2F1$Perspective, paired=T))
myttest$statistic[[1]]^2
## Repeated-measures ANOVA (with aov())
summary(aov(Average~Perspective+Error(Subject/Perspective), MT2F1))
## Repeated-measures ANOVA (with ezANOVA())
library(ez)
ezANOVA(
data = MT2F1
, dv = Average
, wid = Subject
, within = Perspective
)
On Fri, 2014-04-04 at 17:50 +0100, Zhenguang Cai wrote:
> Hi,
>
> I keep having radically different results for LME (especially when
> random slopes are included, due to Barr et al. 2013) between different
> versions of R (and supposedly different lme4 packages) (I wonder
> anyone else encounter similar problems), so I am turning back to the
> good old ANOVA.
>
> I had a repeated measure design, with Perspective as two-level
> within-subject factor (Agent vs. Recipient). So I ran an ANOVA
> analysis in R, using
>
> aov(Average~Perspective+Error(Subject/Perspective), MT2F1)
>
> and the following are the results
>
> ***********************
> Error: Subject
> Df Sum Sq Mean Sq F value Pr(>F)
> Residuals 22 3.176 0.1444
>
> Error: Subject:Perspective
> Df Sum Sq Mean Sq F value Pr(>F)
> Perspective 1 1.1414 1.1414 37.08 3.96e-06 ***
> Residuals 22 0.6772 0.0308
> ---
> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
> *************************
>
> However, I found the F-value was much larger than the F-value (37.08)
> I observed in SPSS (5.92) (using the same data set). I wonder whether
> I used a wrong formula.
>
> Also, I want to include a covariate "Pnum". I wonder the following is
> the correct formula:
>
> aov(Average~(Perspective+Pnum)+Error(Subject/Perspective), MT2F1)
>
> Thanks,
>
> Zhenguang Cai
>
> --
> Zhenguang Cai
>
> Department of Cogntive, Perceptual and Brain Sciences
> University College London
>
> https://sites.google.com/site/zhenguangcai/
More information about the ling-r-lang-L
mailing list