不同的aov结果在不同的计算机上(也与ezANOVA不同)

时间:2013-12-19 20:46:45

标签: r anova mixed-models

我无法弄清楚我为混合ANOVA运行的R代码有什么问题。令人沮丧的是,我在不同的计算机上获得了不同的aov功能结果(一个是Mac,另一个是PC)。另外,我在Mac上使用aov功能获得的结果与我在同一台计算机上使用ezANOVA时得到的结果大不相同。我在SPSS中运行相同的分析并获得与ezANOVA相同的结果,因此我的aov系列似乎有问题。但是,正如我之前所说,我在PC上使用相同的代码和数据文件获得了不同的结果。我很偏执,这个问题非常简单,但是我无法理解它,这也妨碍了我完成分析。

我可能做过的事情搞砸了我的默认设置吗?我甚至重新启动了计算机,但仍然得到了相同的结果。

> 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

非常感谢任何帮助!

1 个答案:

答案 0 :(得分:2)

你的问题就在警告中。 ezANOVA正在将您的预测变量转换为因子aov(来自自由度)显然不是。ezANOVA当你修复它时,你至少会发现交互是相同的。

但是一旦你正确地进行分析,你仍然会发现差异,可能是由于不相等的细胞大小。这是因为aov正在执行类型III分析(SPSS中的默认值),而{{1}}正在执行类型I或顺序分析。你需要决定你需要哪些。

很难评论Mac到PC的问题,因为结果没有公布,但我在平台上的某个地方打赌你修复了Mac平台中的因素问题。