Lecture #22: Beyond the ANOVA Procedure

STAT 200 – Introductory Statistics

Torin Quinlivan

Knox College

February 21, 2026

Review: Procedure Requirements

Always, we have to make assumptions in determining the distribution of the test statistic. In many cases, you saw the assumptions. In some, they were hidden.

Review: Procedure Requirements

Test Assumption
\(Z\)-test Normality
\(t\)-test Normality
Variance Test Normality
Wilcoxon Test Symmetry
Mann-Whitney Test none
Binomial Test none
Proportions Test Normality
Chi-Square Goodness-of-Fit Test Normality

ANOVA Requirements

For the analysis of variance procedure, there are two assumptions that we needed to make:

  • Normality in each group.
  • Equal variances across the groups.

ANOVA Requirements

These assumptions can be tested using the following tests:

  • Shapiro-Wilk test (shapiroTest)
  • Fligner-Killeen test (fligner.test)

The null hypothesis for each test is:

  • \(H_0 :\) the data are from a Normal distribution.
  • \(H_0 :\) The variances are equal. (\(\sigma_1^2 = \sigma_2^2 = \dots = \sigma_k^2\))

Thus, small \(p\)-values indicate the requirement is not met by the data.

Example #1: Rice Yields

Does rice variety influence average yield amongst these four varieties?

First, because we are testing for independence between a numeric variable (yield) and a categorical variable (variety), we would like to use the analysis of variance procedure.

The hypotheses are:

\[ \begin{aligned} H_0 &: \mu_1 = \mu_2 = \mu_3 = \mu_4 \\ H_A &: \textrm{At least one of the means differs from the others.} \end{aligned} \]

Example #1: Rice Yields

The following code loads the data and tests the assumptions:

    library(KnoxStats)
    rice = read.csv("http://rfs.kvasaheim.com/data/rice.csv")
    attach(rice)
    
    shapiroTest(yield ~ variety)
Shapiro-Wilk Test 
Adjustment: Bonferroni correction (k = 4 ) 

 Level   p.value
     A 0.3148640
     B 1.0000000
     C 0.5065811
     D 0.8381207
    fligner.test(yield ~ variety)

    Fligner-Killeen test of homogeneity of variances

data:  yield by variety
Fligner-Killeen:med chi-squared = 1.0026, df = 3, p-value = 0.8006

Example #1: Rice Yields

Incomplete Conclusion: We are asked to determine if the rice yield and the rice variety are independent. To do this, we would prefer to use the analysis of variance procedure, because it is the most powerful of the available tests. It has two requirements: The data are from a Normal distribution in each group; and the variances are the same across the groups. Neither assumption is violated. The minimum \(p\)-value from the Shapiro-Wilk test is \(0.0787\), which is greater than \(\alpha = 0.05\). The \(p\)-value from the Fligner-Killeen test, \(0.8006\), is also greater than our \(\alpha = 0.05\). Because neither assumption is violated, we can use the analysis of variance procedure.

The small \(p\)-value of \(0.00503\) of the ANOVA procedure indicates that the two variables, yield and variety, are dependent. Not all varieties have the same average yield.

Beyond ANOVA

Note that the conclusion was at least one mean differed from the others. That is hardly helpful.

What we really want to know is “which variety is different?”

ANOVA cannot answer that question.

Tukey’s HSD Test

However, there is a procedure that can answer it: Tukey’s Honestly Significant Difference Test.

Its assumptions are the same as for ANOVA. So, if you use ANOVA, then you can use Tukey’s HSD test.

Tukey’s HSD Test

The code to perform Tukey’s HSD test on our model is:

ricemod = aov(yield ~ variety)

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

Fit: aov(formula = yield ~ variety)

$variety
      diff         lwr      upr     p adj
B-A -56.25 -191.592699  79.0927 0.6185496
C-A -46.00 -181.342699  89.3427 0.7473470
D-A 132.00   -3.342699 267.3427 0.0567296
C-B  10.25 -125.092699 145.5927 0.9957690
D-B 188.25   52.907301 323.5927 0.0066015
D-C 178.00   42.657301 313.3427 0.0097522

Tukey’s HSD Test

Find the \(p\)-values and interpret them for the null hypothesis “the difference in averages between these two levels is 0.”

At our usual level of significance, we were only able to detect differences in average yield between Varieties B and D and between Varieties C and D.

Variety D has a higher average yield than Variety B by between 53 and 324.

Variety D has a higher average yield than Variety C by between 43 and 313.

We did not detect a difference between average yield between any other comparisons.

Tukey’s HSD Test

These conclusions are hardly surprising in light of the data:

Kruskal-Wallis Test

If any of the assumptions necessary for ANOVA are violated, you should not use ANOVA.

Like the \(t\)-test, there is a non-parametric alternative to ANOVA. It is called the Kruskal-Wallis test.

  • It has the same requirements as the Mann-Whitney test.
  • It is a part of the agricolae package, which you have to install.
  • Its output is simpler than that of ANOVA.
  • It has its own multiple comparisons test, the Kruskal (multiple comparisons) test.
  • The Kruskal test output is also simpler than that of Tukey’s HSD.

Example #2: Citizen’s Initiative

The citizen’s initiatize allows the people of the state to force a vote on a given issue. Do the different political cultures use the initiative at the same rates?

The hypotheses are:

\[ \begin{aligned} H_0 &: \mu_m = \mu_i = \mu_t \\ H_A &: \textrm{At least one of the means differs from the others.} \end{aligned} \]

Example #2: Citizen’s Initiative

Because we are comparing multiple means, we would like to use the ANOVA procedure. It has two assumptions:

  • The data come from a Normal distribution in each group.
  • The data have the same variance across the groups.

Example #2: Citizen’s Initiative

To check this using R, we run the following code:

shapiroTest(inituse ~ domPolCulture)
Shapiro-Wilk Test 
Adjustment: Bonferroni correction (k = 3 ) 

            Level      p.value
       Moralistic 2.048182e-03
  Individualistic 1.357651e-03
 Traditionalistic 9.940607e-06
fligner.test(inituse ~ domPolCulture)

    Fligner-Killeen test of homogeneity of variances

data:  inituse by domPolCulture
Fligner-Killeen:med chi-squared = 10.007, df = 2, p-value = 0.006715

Example #2: Citizen’s Initiative

Because at least one requirement was not met, we should not use ANOVA.

We will use the Kruskal-Wallis test:

kruskal.test(inituse, domPolCulture)

    Kruskal-Wallis rank sum test

data:  inituse and domPolCulture
Kruskal-Wallis chi-squared = 6.3238, df = 2, p-value = 0.04235

Because the \(p\)-value is less that our usual \(\alpha = 0.05\), we reject the null hypothesis. We can conclude that at least one mean differs from the others. Which one?

Example #2: Citizen’s Initiative

To determine which is different, we use Kruskal’s multiple comparisons test:

print(kruskal(inituse, domPolCulture))
$statistics
     Chisq Df    p.chisq  t.value      MSD
  6.323785  2 0.04234553 2.010635 8.932211

$parameters
            test p.ajusted        name.t ntr alpha
  Kruskal-Wallis      none domPolCulture   3  0.05

$means
                   inituse     rank       std  r Min Max Q25 Q50 Q75
Individualistic   4.705882 24.91176  6.272606 17   0  18   0   0  10
Moralistic       14.764706 32.32353 19.533719 17   0  60   0   8  16
Traditionalistic  2.764706 20.76471  5.984662 17   0  23   0   0   2

$comparison
NULL

$groups
                  inituse groups
Moralistic       32.32353      a
Individualistic  24.91176     ab
Traditionalistic 20.76471      b

attr(,"class")
[1] "group"

Example #2: Citizen’s Initiative

Treatments with the same letter are not significantly different.

From this, we know we detected a difference in average initiative use between the moralistic states and the traditionalistic states. No other differences were detected.

Example #2: Citizen’s Initiative

Conclusion:

We are asked to determine if the initiative use and the political culture are independent. To do this, we would prefer to use the analysis of variance procedure, because it is the most powerful of the available tests. It has two requirements: The data are from a Normal distribution in each group; and the variances are the same across the groups. Both assumptions are violated. The maximum \(p\)-value from the Shapiro-Wilk test is 0.00204, which is much less than \(\alpha = 0.05\). The \(p\)-value from the Fligner-Killeen test, 0.0067, is also less than our \(\alpha = 0.05\). Because both assumptions are violated, we should not use the analysis of variance procedure. We must use the Kruskal-Wallis test.

Example #2: Citizen’s Initiative

Conclusion:

The small \(p\)-value of 0.0424 of the Kruskal-Wallis test indicates that the two variables, initiative use and political culture are dependent. Not all political cultures use the initiative process equally. According to the Kruskal multiple comparisons test, we can conclude that states with a moralistic political culture tend to use the initiative more frequently than states with a traditionalistic culture. No other comparisons were significant.

Example #2: Citizen’s Initiative

Again, these conclusions make sense when seeing the graphic:

Example #3: Violent Crime

Does the 2000 violent crime rate significantly vary across the four census regions?

The hypotheses are:

\[ \begin{aligned} H_0 &: \mu_N = \mu_S = \mu_M = \mu_W \\ H_A &: \textrm{At least one of the means differs from the others.} \end{aligned} \]

Example #3: Violent Crime

Because we are comparing multiple means, we would like to use the ANOVA procedure. It has two assumptions:

  • The data come from a Normal distribution in each group.
  • The data have the same variance across the groups.

Example #3: Violent Crime

To check this using R, we run the following code:

shapiroTest(vcrime00 ~ census4)
Shapiro-Wilk Test 
Adjustment: Bonferroni correction (k = 4 ) 

     Level   p.value
 Northeast 1.0000000
   Midwest 1.0000000
     South 0.2251474
      West 1.0000000
fligner.test(vcrime00 ~ census4)

    Fligner-Killeen test of homogeneity of variances

data:  vcrime00 by census4
Fligner-Killeen:med chi-squared = 6.0913, df = 3, p-value = 0.1073

Example #3: Violent Crime

Because no requirement was violated, we can use ANOVA. Here is the code:

cmod1 = aov(vcrime00 ~ census4)
summary(cmod1)
            Df  Sum Sq Mean Sq F value  Pr(>F)   
census4      3  689569  229856   4.855 0.00505 **
Residuals   47 2225268   47346                   
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Because the \(p\)-value of 0.00505 is less than our usual \(\alpha = 0.05\), we reject the null hypothesis. We can conclude that at least one mean differs from the others. Again, which one?

Example #3: Violent Crime

To determine which is different, we use the Tukey HSD test.

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

Fit: aov(formula = vcrime00 ~ census4)

$census4
                        diff        lwr       upr     p adj
Northeast-Midwest  -55.21111 -310.76041 200.33819 0.9389452
South-Midwest      196.87647  -21.62826 415.38120 0.0910331
West-Midwest       -74.66154 -306.65974 157.33667 0.8266966
South-Northeast    252.08758   13.18663 490.98853 0.0350137
West-Northeast     -19.45043 -270.75207 231.85122 0.9968573
West-South        -271.53801 -485.05941 -58.01661 0.0075817

From this, we now we detected a difference in average violent crime rate between the South and Northwest states and the West and South states, where the South is significantly higher than the Northeast and the South is significantly higher that the West.

Example #3: Violent Crime

Conclusion:

We are asked to determine if the violent crime rate and the census region are independent. To do this, we would prefer to use the analysis of variance procedure, because it is the most powerful of the available tests. It has two requirements: The data are from a Normal distribution in each group; and the variances are the same across the groups. Neither assumption is violated. The minimum \(p\)-value from the Shapiro-Wilk test is 0.2251, which is greater than \(\alpha = 0.05\). The \(p\)-value from the Fligner-Killeen test, 0.1073, is also greater than our \(\alpha = 0.05\). Because neither assumption is violated, we can – and should – use the analysis of variance procedure.

Example #3: Violent Crime

Conclusion:

The small \(p\)-value of 0.00505 of the ANOVA test indicates that the two variables, violent crime rate and census region are dependent. Not all census regions have the same average violent crime rate. According to Tukey’s HSD test, we can conclude that southern states have a significantly higher average violent crime rate than the Northeastern states and the Western states. No other comparisons were significant.

Example #4: Education

Does the 2000 violent crime rate significantly vary across the four census regions?

The hypotheses are:

\[ \begin{aligned} H_0 &: \textrm{All the means are the same.} \\ H_A &: \textrm{At least one of the means differs from the others.} \end{aligned} \]

Example #4: Education

Because we are comparing multiple means, we would like to use the ANOVA procedure. It has two assumptions:

  • The data come from a Normal distribution in each group.
  • The data have the same variance across the groups.

Example #4: Education

To check this using R, we run the following code:

shapiroTest(waea00 ~ domPolCulture)
Shapiro-Wilk Test 
Adjustment: Bonferroni correction (k = 3 ) 

            Level   p.value
       Moralistic 0.6071567
  Individualistic 1.0000000
 Traditionalistic 1.0000000
fligner.test(waea00 ~ domPolCulture)

    Fligner-Killeen test of homogeneity of variances

data:  waea00 by domPolCulture
Fligner-Killeen:med chi-squared = 2.8698, df = 2, p-value = 0.2381

Example #4: Education

Because no requirement was violated, we can use ANOVA. Here is the code:

waeamod = aov(waea00 ~ domPolCulture)
summary(waeamod)
              Df Sum Sq Mean Sq F value   Pr(>F)    
domPolCulture  2  276.0  138.02   17.19 2.35e-06 ***
Residuals     48  385.4    8.03                     
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Because the \(p\)-value is much less than our usual \(\alpha = 0.05\), we reject the null hypothesis. We can conclude that at least one mean differs from the others. Which one?

Example #4: Education

To determine which is different, we use the Tukey HSD test.

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

Fit: aov(formula = waea00 ~ domPolCulture)

$domPolCulture
                                      diff        lwr       upr     p adj
Moralistic-Individualistic        1.725882 -0.6247889  4.076554 0.1885858
Traditionalistic-Individualistic -3.840588 -6.1912595 -1.489917 0.0007316
Traditionalistic-Moralistic      -5.566471 -7.9171418 -3.215799 0.0000019

From this, we now we detected a difference in average WAEA rate between the traditionalist states and both of the other two types. In both cases, the traditionalistic states tended to have lower WAEA. No other comparisons were statistically significant.

Example #4: Education

Conclusion:

We are asked to determine if the violent crime rate and the census region are independent. To do this, we would prefer to use the analysis of variance procedure, because it is the most powerful of the available tests. It has two requirements: The data are from a Normal distribution in each group; and the variances are the same across the groups. Neither assumption is violated. The minimum \(p\)-value from the Shapiro-Wilk test is 0.6072, which is greater than \(\alpha = 0.05\). The \(p\)-value from the Fligner-Killeen test, 0.2381, is also greater than our \(\alpha = 0.05\). Because neither assumption is violated, we can – and should – use the analysis of variance procedure.

Example #4: Education

Conclusion:

The small \(p\)-value of \(2.35 \times 10^{-6}\) of the ANOVA test indicates that the two variables, WAEA and dominant political culture are dependent. According to Tukey’s HSD test, we can conclude that traditionalistic states have a significantly lower average WAEA than the moralistic and individualistic states. No other comparisons were significant.

Example #5: Average Wealth

Does the 2000 GSP per capita significantly vary across the three political cultures?

The hypotheses are:

\[ \begin{aligned} H_0 &: \mu_I = \mu_M = \mu_T \\ H_A &: \textrm{At least one of the means differs from the others.} \end{aligned} \]

Example #5: Average Wealth

Because we are comparing multiple means, we would like to use the ANOVA procedure. It has two assumptions:

  • The data come from a Normal distribution in each group.
  • The data have the same variance across the groups.

Example #5: Average Wealth

To check this using R, we run the following code:

shapiroTest(gspcap00 ~ domPolCulture)
Shapiro-Wilk Test 
Adjustment: Bonferroni correction (k = 3 ) 

            Level      p.value
       Moralistic 7.771441e-01
  Individualistic 7.609321e-03
 Traditionalistic 3.239349e-05
fligner.test(gspcap00 ~ domPolCulture)

    Fligner-Killeen test of homogeneity of variances

data:  gspcap00 by domPolCulture
Fligner-Killeen:med chi-squared = 0.77112, df = 2, p-value = 0.6801

Example #5: Average Wealth

Because at least one requirement was violated, we should not use ANOVA. We need to use the Kruskal-Wallis test. Here is the code:

kruskal.test(gspcap00 ~ domPolCulture)

    Kruskal-Wallis rank sum test

data:  gspcap00 by domPolCulture
Kruskal-Wallis chi-squared = 13.752, df = 2, p-value = 0.001032

Because the \(p\)-value of 0.0010 is less than our usual \(\alpha = 0.05\), we reject the null hypothesis. We can conclude that at least one mean differs from the others. Which one? [fragile=singleslide]

Example #5: Average Wealth

To determine which is different, we use Kruskal’s multiple comparisons test:

print(kruskal(gspcap00, domPolCulture))
$statistics
     Chisq Df     p.chisq  t.value      MSD
  13.75193  2 0.001032301 2.010635 8.909261

$parameters
            test p.ajusted        name.t ntr alpha
  Kruskal-Wallis      none domPolCulture   3  0.05

$means
                 gspcap00     rank       std  r      Min      Max      Q25
Individualistic  39160.74 36.35294  8429.325 17 31213.49 65117.14 32644.85
Moralistic       32676.14 23.82353  4466.155 17 24059.87 39372.47 29760.26
Traditionalistic 32455.14 17.82353 12116.530 17 22636.06 76483.42 26831.35
                      Q50      Q75
Individualistic  37548.27 42483.13
Moralistic       31445.69 37002.88
Traditionalistic 29509.63 33909.05

$comparison
NULL

$groups
                 gspcap00 groups
Individualistic  36.35294      a
Moralistic       23.82353      b
Traditionalistic 17.82353      b

attr(,"class")
[1] "group"

Treatments with the same letter are not significantly different.

Example #5: Average Wealth

From this, we now we detected a difference in average GSP per capita between the individualistic states and both of the other two types. In both cases, the individualistic states tended to have higher GSP per capita. No other comparisons were statistically significant.

Example #5: Average Wealth

Conclusion:

We are asked to determine if the average GSP per capita and the dominant political culture are independent. To do this, we would prefer to use the analysis of variance procedure, because it is the most powerful of the available tests. It has two requirements: The data are from a Normal distribution in each group; and the variances are the same across the groups. The Normality assumption is violated. The minimum \(p\)-value from the Shapiro-Wilk test is 0.000033, which is much less than \(\alpha = 0.05\). Because an assumption is violated, we need to use the Kruskal-Wallis test.

Example #5: Average Wealth

Conclusion:

The small \(p\)-value of 0.0010 of the Kruskal-Wallis test indicates that the two variables, GSP per capita and dominant political culture are dependent. According to the Kruskal multiple comparison test, we can conclude that individualist states have a significantly higher GSP per capita than the moralistic and traditionalistic. No other comparisons were significant.

Example #6: Legislature Professionalism

Does the professional level of the state’s legislature significantly vary across the three political cultures?

The hypotheses are:

\[ \begin{aligned} H_0 &: \mu_I = \mu_M = \mu_T \\ H_A &: \textrm{At least one of the means differs from the others.} \end{aligned} \]

Example #6: Legislature Professionalism

Because we are comparing multiple means, we would like to use the ANOVA procedure. It has two assumptions:

  • The data come from a Normal distribution in each group.
  • The data have the same variance across the groups.

Example #6: Legislature Professionalism

To check this using R, we run the following code:

shapiroTest(profleg ~ domPolCulture)
Shapiro-Wilk Test 
Adjustment: Bonferroni correction (k = 3 ) 

            Level     p.value
       Moralistic 0.002017848
  Individualistic 0.033975358
 Traditionalistic 1.000000000
fligner.test(profleg ~ domPolCulture)

    Fligner-Killeen test of homogeneity of variances

data:  profleg by domPolCulture
Fligner-Killeen:med chi-squared = 5.1794, df = 2, p-value = 0.07504

Example #6: Legislature Professionalism

Because at least one requirement was violated, we should not use ANOVA. We need to use the Kruskal-Wallis test. Here is the code:

kruskal.test(profleg ~ domPolCulture)

    Kruskal-Wallis rank sum test

data:  profleg by domPolCulture
Kruskal-Wallis chi-squared = 6.5777, df = 2, p-value = 0.0373

Because the \(p\)-value of 0.0373 is less than our usual \(\alpha = 0.05\), we reject the null hypothesis. We can conclude that at least one mean differs from the others. Which one?

Example #6: Legislature Professionalism

To determine which is different, we use Kruskal’s multiple comparisons test:

print(kruskal(profleg, domPolCulture))
$statistics
     Chisq Df    p.chisq
  6.577695  2 0.03729682

$parameters
            test p.ajusted        name.t ntr alpha
  Kruskal-Wallis      none domPolCulture   3  0.05

$means
                   profleg     rank        std  r  Min  Max  Q25   Q50    Q75
Individualistic  0.2764706 32.82353 0.15519911 17 0.06 0.66 0.19 0.260 0.3100
Moralistic       0.2152941 22.35294 0.17507561 17 0.04 0.65 0.11 0.160 0.2300
Traditionalistic 0.1712500 21.06250 0.05264662 16 0.10 0.26 0.13 0.165 0.2025

$comparison
NULL

$groups
                  profleg groups
Individualistic  32.82353      a
Moralistic       22.35294      b
Traditionalistic 21.06250      b

attr(,"class")
[1] "group"

Treatments with the same letter are not significantly different.

Example #6: Legislature Professionalism

From this, we now we detected a difference in average level of legislative professionalism between the individualistic states and both of the other two types. In both cases, the individualistic states tended to have higher levels of legislative professionalism. No other comparisons were statistically significant.

Example #6: Legislature Professionalism

Conclusion:

We are asked to determine if the level of legislative professionalism and the dominant political culture are independent. To do this, we would prefer to use the analysis of variance procedure, because it is the most powerful of the available tests. It has two requirements: The data are from a Normal distribution in each group; and the variances are the same across the groups. The Normality assumption is violated. The minimum \(p\)-value from the Shapiro-Wilk test is 0.0020, which is much less than \(\alpha = 0.05\). Because an assumption is violated, we need to use the Kruskal-Wallis test.

Example #6: Legislature Professionalism

Conclusion:

The small \(p\)-value of 0.0373 of the Kruskal-Wallis test indicates that the two variables, legislative professionalism and dominant political culture, are dependent. According to Kruskal’s multiple comparisons test, we can conclude that individualistic states tend to have a significantly higher level of legislative professionalism than the moralistic and traditionalistic states. No other comparisons were significant.