Search code examples
rtukey

ANOVA gives me a significant P value, but Tukey's HSD categorizes everything as the same letter. What am I doing wrong to cause this?


When I look at an ANOVA for my dataset, I get a P-value of 0.018, which is significant at alpha=0.05. However, when I do a Tukey's HSD test on that ANOVA, everything is categorized as falling into group A. Can anyone explain what's going on here?

Here's my data:

dataHodag <- read.table(text="
   Plot Rate Rep HollowHeartPercent
1  2155    1   1                0.0
2  2252    1   2                0.2
3  2343    1   3                0.2
4  2433    1   4                0.2
5  2211    2   2                0.0
6  2326    2   3                0.0
7  2412    2   4                0.0
8  2136    2   1                0.2
9  2124    3   1                0.0
10 2334    3   3                0.0
11 2421    3   4                0.0
12 2236    3   2                0.2
13 2246    4   2                0.0
14 2354    4   3                0.0
15 2446    4   4                0.0
16 2116    4   1                0.1
17 2145    5   1                0.0
18 2225    5   2                0.0
19 2314    5   3                0.0
20 2451    5   4                0.0", header=TRUE)

I am using the agricolae package for my analysis This is the code that gives me my ANOVA:

TukeyAOV <- aov(HollowHeartPercent ~ Rep + Rate, data=dataHodag)
summary(TukeyAOV)
#             Df  Sum Sq Mean Sq F value Pr(>F)  
# Rep          1 0.00250 0.00250   0.406  0.533  
# Rate         1 0.04225 0.04225   6.857  0.018 *
# Residuals   17 0.10475 0.00616                 
# ---
# Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

And here is the code for my Tukey's HSD test:

HSD <- agricolae::HSD.test(TukeyAOV, "Rate", alpha = 0.05, group=TRUE)
print(HSD$groups)
#  HollowHeartPercent groups
# 1              0.150      a
# 2              0.050      a
# 3              0.050      a
# 4              0.025      a
# 5              0.000      a

Any help would be much appreciated. Thanks!!


Solution

  • Did you notice the discrepancy in degrees of freedom? You read Rate and Rep as numeric variables, not as factors. Compare to:

    > dataHodag$Plot <- as.factor(dataHodag$Plot)
    > dataHodag$Rate <- as.factor(dataHodag$Rate)
    > TukeyAOV <- aov(HollowHeartPercent ~ Rep + Rate, data=dataHodag)
    > summary(TukeyAOV)
                Df Sum Sq  Mean Sq F value Pr(>F)
    Rep          1 0.0025 0.002500   0.368  0.554
    Rate         4 0.0520 0.013000   1.916  0.164
    Residuals   14 0.0950 0.006786               
    

    I hope this helps.