1

在进行大方差分析时,有时我们需要使用 Tukey HSD 检验来验证配对显着性。由于这是一项耗时的任务,想请教一下如何进行部分测试。我的意思是,我知道summary(aov)之后的重要项目,我只想对主要项目做Tukey HSD,其余的去掉。这是参考代码:

seed(100)
# create the DF for aov
X <- rep(letters[1:3],each=6)
Y <- rep(sample(100,3),each=6)
Z <- rep(rep(LETTERS[3:4],9))
m <- data.frame(X,Y,Z)

# do aov and summary
fit <- aov(Y~X+Z, data=m)

summary(fit)

#             Df Sum Sq Mean Sq   F value Pr(>F)    
# X            2   7756    3878 1.329e+30 <2e-16 ***
# Z            1      0       0 7.260e-01  0.409    
# Residuals   14      0       0                     
# ---
# Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

TukeyHSD(fit)
#  Tukey multiple comparisons of means
#    95% family-wise confidence level

# Fit: aov(formula = Y ~ X + Z, data = m)

# $`X`
#     diff lwr upr p adj
# b-a    4   4   4     0
# c-a   -1  -1  -1     0
# c-b   -5  -5  -5     0

# $Z
#           diff           lwr          upr     p adj
# D-C          0 -2.363621e-15 2.363621e-15         1

我可以只做X,而不是Z吗?像TukeyHSD(fit[["X"]])什么?

顺便说一句,为什么有$'X',但不是 $Z?非常感谢。

4

0 回答 0