Reputation: 507
I am having trouble figuring out what is wrong with the R code I am running for a mixed ANOVA. Frustratingly, I'm getting different results for the aov function on different computers (one is Mac, the other is PC). Also, the results I get with the aov function on the Mac are extremely different from what I get with ezANOVA on the same computer. I've run the same analyses in SPSS and get the same results as with ezANOVA so it seems to be something wrong with my aov line. However, as I said previously, I get a different result on my PC with the same code and data file. I'm paranoid the problem is something really simple but I can't figure it out and it's getting in the way of completing my analyses.
Is there something I may have done that has messed up my default settings? I even rebooted the computer and I still get the same results.
> ex.data <- structure(list(RT = c(459.15, 506.75, 382.05, 395.75, 422.263157894737,
374, 433.75, 401.85, 573.8, 473.15, 335.35, 405.842105263158,
390.05, 354.35, 369.7, 650.421052631579, 400.8, 426.8, 477.6,
517.05, 451.3, 405.9, 380.15, 346, 595.8, 336, 451.5, 440.55,
718.3, 439.55, 423.05, 560, 669.333333333333, 525.578947368421,
358.75, 505.8, 426, 417.4, 361.65, 409.85, 486.631578947368,
540, 438, 357.2, 401.35, 407.45, 397.166666666667, 406.052631578947,
445.85, 467.6, 353.35, 366.3, 431.6, 326.6, 433.105263157895,
347.75, 512.105263157895, 443.85, 296.85, 408.058823529412, 364.3,
315.9, 341.5, 646.058823529412, 373.5, 414.45, 475.45, 489.45,
429.368421052632, 419.35, 370.2, 327.75, 569.85, 347, 415.35,
429.5, 738.15, 406.4, 400.3, 522.941176470588, 631.555555555556,
484.9, 355.684210526316, 465.9, 415.5, 445.631578947368, 400.555555555556,
387.4, 477.3, 503.95, 404, 394.5, 385.65, 383.55, 439.65, 371.421052631579),
TrialType = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c("dtprb.con.neg", "dtprb.incon.neg"
), class = "factor"), subject = c(2L, 3L, 5L, 6L, 7L, 9L, 10L,
11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 100L, 101L, 102L, 103L,
106L, 107L, 108L, 109L, 110L, 111L, 112L, 113L, 114L, 116L, 118L,
119L, 120L, 121L, 122L, 123L, 124L, 125L, 126L, 127L, 128L, 200L,
201L, 204L, 206L, 210L, 211L, 400L, 401L, 2L, 3L, 5L, 6L, 7L,
9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 100L, 101L,
102L, 103L, 106L, 107L, 108L, 109L, 110L, 111L, 112L, 113L, 114L,
116L, 118L, 119L, 120L, 121L, 122L, 123L, 124L, 125L, 126L, 127L,
128L, 200L, 201L, 204L, 206L, 210L, 211L, 400L, 401L), condition = c("placebo",
"drug", "placebo", "drug", "placebo", "drug", "placebo", "drug",
"drug", "placebo", "drug", "drug", "placebo", "placebo", "drug",
"placebo", "placebo", "drug", "drug", "placebo", "drug", "placebo",
"drug", "drug", "drug", "placebo", "placebo", "drug", "placebo",
"drug", "drug", "drug", "placebo", "placebo", "placebo", "drug",
"drug", "placebo", "placebo", "drug", "placebo", "placebo", "placebo",
"placebo", "drug", "drug", "drug", "placebo", "placebo", "drug",
"placebo", "drug", "placebo", "drug", "placebo", "drug", "drug",
"placebo", "drug", "drug", "placebo", "placebo", "drug", "placebo",
"placebo", "drug", "drug", "placebo", "drug", "placebo", "drug",
"drug", "drug", "placebo", "placebo", "drug", "placebo", "drug",
"drug", "drug", "placebo", "placebo", "placebo", "drug", "drug",
"placebo", "placebo", "drug", "placebo", "placebo", "placebo",
"placebo", "drug", "drug", "drug", "placebo")), .Names = c("RT",
"TrialType", "subject", "condition"), row.names = c(NA, -96L), class = "data.frame")
> anova_ex.data <- aov(RT ~ TrialType*condition + Error(subject/TrialType) + condition, data=ex.data)
> summary(anova_ex.data)
Error: subject
Df Sum Sq Mean Sq
condition 1 3267 3267
Error: subject:TrialType
Df Sum Sq Mean Sq
TrialType 1 1738 1738
Error: Within
Df Sum Sq Mean Sq F value Pr(>F)
TrialType 1 6747 6747 0.883 0.350
condition 1 16743 16743 2.191 0.142
TrialType:condition 1 763 763 0.100 0.753
Residuals 90 687713 7641
> ezANOVA(data = ex.data, dv = .(RT), wid = .(subject), within = .(TrialType), between = .(condition), detailed = TRUE, type = 3)
Warning: Converting "subject" to factor for ANOVA.
Warning: Converting "condition" to factor for ANOVA.
$ANOVA
Effect DFn DFd SSn SSd F p p<.05 ges
1 (Intercept) 1 46 8620839.9719 678628.80 584.352798 8.648708e-28 * 0.925761817
2 condition 1 46 17592.2597 678628.80 1.192469 2.805185e-01 0.024815931
3 TrialType 1 46 6552.8332 12688.87 23.755499 1.340138e-05 * 0.009389755
4 condition:TrialType 1 46 887.0503 12688.87 3.215757 7.950840e-02 0.001281485
Any help is greatly appreciated!
Upvotes: 1
Views: 566
Reputation: 23758
Your problem is right there in the warnings. ezANOVA
is converting your predictors to factors while aov
(from the degrees of freedom) is clearly not. When you fix that you'll at least find that the interactions are identical.
But once you're doing the analysis correctly you will still find differences, perhaps due to unequal cell sizes. It's because ezANOVA
is performing a Type III analysis (default in SPSS) while aov
is performing a Type I or sequential analysis. You need to decide which of these you need.
It's hard to comment on the Mac to PC issue because the results aren't posted but I'm betting somewhere in the translation across platforms you fixed the factor problem that's here in the Mac platform.
Upvotes: 2