1
votes

I want to perform a post-hoc duncan test (use "agricolae" package in r) after running one-way anova comparing the means of 3 groups.

## 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

However, the output only tells me the mean of PGY1 and PGY2 are different without p-values for each group comparison ( post-hoc pairwise t tests would generate p-values for each group comparison).

How can I get p value from a duncan test?

Thanks!!

1

1 Answers

2
votes

One solution would be to use PostHocTest from the DescTools package.

Here is an example using the warpbreaks sample data.

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

The pairwise differences between the means for every group are given in the first column (e.g. M-L, and so on), along with confidence intervals and p-values.

For example, the difference in the mean breaks between H and M is not statistically significant.


If performing Duncan's test is not a critical requirement, you can also run pairwise.t.test with various other multiple comparison corrections. For example, using Bonferroni's method

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

Results are consistent with those from the post-hoc Duncan's test.