从 post-hoc duncan test in r 中获取 p 值
get p-values from post-hoc duncan test in r
我想在 运行 单向方差分析比较 3 组的平均值之后执行 post-hoc duncan 检验(在 r 中使用 "agricolae" 包)。
## run one-way anova
> t1 <- aov(q3a ~ pgy,data = pgy)
> summary(t1)
Df Sum Sq Mean Sq F value Pr(>F)
pgy 2 13 6.602 5.613 0.00367 **
Residuals 6305 7416 1.176
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
1541 observations deleted due to missingness
## run post-hoc duncan test
> duncan.test(t1,"pgy",group = T, console = T)
Study: t1 ~ "pgy"
Duncan's new multiple range test
for q3a
Mean Square Error: 1.176209
pgy, means
q3a std r Min Max
PGY1 1.604292 1.068133 2656 1 5
PGY2 1.711453 1.126446 2017 1 5
PGY3 1.656269 1.057937 1635 1 5
Groups according to probability of means differences and alpha level( 0.05 )
Means with the same letter are not significantly different.
q3a groups
PGY2 1.711453 a
PGY3 1.656269 ab
PGY1 1.604292 b
但是,输出仅告诉我 PGY1 和 PGY2 的平均值不同,没有每个组比较的 p 值(post-hoc 成对 t 检验将为每个组比较生成 p 值)。
如何从邓肯检验中获得 p 值?
谢谢!!
一个解决方案是使用 DescTools
包中的 PostHocTest
。
这是一个使用 warpbreaks
示例数据的示例。
require(DescTools);
res <- aov(breaks ~ tension, data = warpbreaks);
PostHocTest(res, method = "duncan");
#
# Posthoc multiple comparisons of means : Duncan's new multiple range test
# 95% family-wise confidence level
#
#$tension
# diff lwr.ci upr.ci pval
#M-L -10.000000 -17.95042 -2.049581 0.01472 *
#H-L -14.722222 -23.08443 -6.360012 0.00072 ***
#H-M -4.722222 -12.67264 3.228197 0.23861
第一列中给出了每组均值之间的成对差异(例如 M-L
,依此类推),以及置信区间和 p 值。
例如,H
和 M
之间的平均间隔差异 不具有 统计显着性。
如果执行 Duncan 检验不是关键要求,您还可以 运行 pairwise.t.test
进行各种其他多重比较校正。例如,使用 Bonferroni 的方法
with(warpbreaks, pairwise.t.test(breaks, tension, p.adj = "bonferroni"));
#
# Pairwise comparisons using t tests with pooled SD
#
#data: breaks and tension
#
# L M
#M 0.0442 -
#H 0.0015 0.7158
#
#P value adjustment method: bonferroni
结果与 post-hoc Duncan 检验的结果一致。
我想在 运行 单向方差分析比较 3 组的平均值之后执行 post-hoc duncan 检验(在 r 中使用 "agricolae" 包)。
## run one-way anova
> t1 <- aov(q3a ~ pgy,data = pgy)
> summary(t1)
Df Sum Sq Mean Sq F value Pr(>F)
pgy 2 13 6.602 5.613 0.00367 **
Residuals 6305 7416 1.176
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
1541 observations deleted due to missingness
## run post-hoc duncan test
> duncan.test(t1,"pgy",group = T, console = T)
Study: t1 ~ "pgy"
Duncan's new multiple range test
for q3a
Mean Square Error: 1.176209
pgy, means
q3a std r Min Max
PGY1 1.604292 1.068133 2656 1 5
PGY2 1.711453 1.126446 2017 1 5
PGY3 1.656269 1.057937 1635 1 5
Groups according to probability of means differences and alpha level( 0.05 )
Means with the same letter are not significantly different.
q3a groups
PGY2 1.711453 a
PGY3 1.656269 ab
PGY1 1.604292 b
但是,输出仅告诉我 PGY1 和 PGY2 的平均值不同,没有每个组比较的 p 值(post-hoc 成对 t 检验将为每个组比较生成 p 值)。
如何从邓肯检验中获得 p 值?
谢谢!!
一个解决方案是使用 DescTools
包中的 PostHocTest
。
这是一个使用 warpbreaks
示例数据的示例。
require(DescTools);
res <- aov(breaks ~ tension, data = warpbreaks);
PostHocTest(res, method = "duncan");
#
# Posthoc multiple comparisons of means : Duncan's new multiple range test
# 95% family-wise confidence level
#
#$tension
# diff lwr.ci upr.ci pval
#M-L -10.000000 -17.95042 -2.049581 0.01472 *
#H-L -14.722222 -23.08443 -6.360012 0.00072 ***
#H-M -4.722222 -12.67264 3.228197 0.23861
第一列中给出了每组均值之间的成对差异(例如 M-L
,依此类推),以及置信区间和 p 值。
例如,H
和 M
之间的平均间隔差异 不具有 统计显着性。
如果执行 Duncan 检验不是关键要求,您还可以 运行 pairwise.t.test
进行各种其他多重比较校正。例如,使用 Bonferroni 的方法
with(warpbreaks, pairwise.t.test(breaks, tension, p.adj = "bonferroni"));
#
# Pairwise comparisons using t tests with pooled SD
#
#data: breaks and tension
#
# L M
#M 0.0442 -
#H 0.0015 0.7158
#
#P value adjustment method: bonferroni
结果与 post-hoc Duncan 检验的结果一致。