我在因子设计中进行了一项实验:我测量了三种食草动物处理和六种营养处理的光 (PAR)。实验被阻止了。
我已经按如下方式运行线性模型(您可以从我的网站下载数据进行复制)
dat <- read.csv('http://www.natelemoine.com/testDat.csv')
mod1 <- lm(light ~ Nutrient*Herbivore + BlockID, dat)
残差图看起来不错
par(mfrow=c(2,2))
plot(mod1)
当我查看 ANOVA 表时,我看到了 Nutrient 和 Herbivore 的主要影响。
anova(mod1)
Analysis of Variance Table
Response: light
Df Sum Sq Mean Sq F value Pr(>F)
Nutrient 5 4.5603 0.91206 7.1198 5.152e-06 ***
Herbivore 2 2.1358 1.06791 8.3364 0.0003661 ***
BlockID 9 5.6186 0.62429 4.8734 9.663e-06 ***
Nutrient:Herbivore 10 1.7372 0.17372 1.3561 0.2058882
Residuals 153 19.5996 0.12810
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
然而,回归表显示了不显着的主效应和显着的交互作用。
summary(mod1)
Call:
lm(formula = light ~ Nutrient * Herbivore + BlockID, data = dat)
Residuals:
Min 1Q Median 3Q Max
-0.96084 -0.19573 0.01328 0.24176 0.74200
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 1.351669 0.138619 9.751 < 2e-16 ***
Nutrientb 0.170548 0.160064 1.066 0.28833
Nutrientc -0.002172 0.160064 -0.014 0.98919
Nutrientd -0.163537 0.160064 -1.022 0.30854
Nutriente -0.392894 0.160064 -2.455 0.01522 *
Nutrientf 0.137610 0.160064 0.860 0.39129
HerbivorePaired -0.074901 0.160064 -0.468 0.64049
HerbivoreZebra -0.036931 0.160064 -0.231 0.81784
...
Nutrientb:HerbivorePaired 0.040539 0.226364 0.179 0.85811
Nutrientc:HerbivorePaired 0.323127 0.226364 1.427 0.15548
Nutrientd:HerbivorePaired 0.642734 0.226364 2.839 0.00513 **
Nutriente:HerbivorePaired 0.454013 0.226364 2.006 0.04665 *
Nutrientf:HerbivorePaired 0.384195 0.226364 1.697 0.09168 .
Nutrientb:HerbivoreZebra 0.064540 0.226364 0.285 0.77594
Nutrientc:HerbivoreZebra 0.279311 0.226364 1.234 0.21913
Nutrientd:HerbivoreZebra 0.536160 0.226364 2.369 0.01911 *
Nutriente:HerbivoreZebra 0.394504 0.226364 1.743 0.08338 .
Nutrientf:HerbivoreZebra 0.324598 0.226364 1.434 0.15362
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.3579 on 153 degrees of freedom
Multiple R-squared: 0.4176, Adjusted R-squared: 0.3186
F-statistic: 4.219 on 26 and 153 DF, p-value: 8.643e-09
我知道这个问题之前已经在多个帖子中被问过和回答。在之前的帖子中,问题围绕 anova() 和 lm() 中使用的不同类型的 SS。但是,我认为这不是这里的问题。首先,设计是平衡的:
with(dat, tapply(light, list(Nutrient, Herbivore), length))
其次,使用 Anova() 选项不会更改 anova 表。这并不奇怪,因为设计是平衡的。
Anova(mod1, type=2)
Anova(mod1, type=3)
改变对比度不会改变结果(定性地)。我仍然从 anova() 与 summary() 中得到了相当多的反向解释。
options(contrasts=c("contr.sum","contr.poly"))
mod2 <- lm(light ~ Nutrient*Herbivore + BlockID, dat)
anova(mod2)
summary(mod2)
我很困惑,因为我在回归上阅读的所有内容都与 ANOVA 不一致,这暗示了 R 将 SS 用于 summary() 和 anova() 函数的方式存在差异。但是,在平衡设计中,SS 类型是等价的,这里的结果不会改变。根据我使用的输出,我怎样才能有完全相反的解释?