Biology, images, analysis, design...
Use/Abuse Principles How To Related
"It has long been an axiom of mine that the little things are infinitely the most important" (Sherlock Holmes)

Search this site



Kruskal-Wallis ANOVA

Worked example 1

Our first worked example uses data from Cobo et al. (1998). They compared albendazole levels in both the serum and in cysts from patients in three treatment groups. They performed both normality and homogeneity of variance tests (results not reported), but then used Kruskal-Wallis to compare the means on the basis of the small sample size. Multiple comparisons were performed with the Wilcoxon-Mann-Whitney test. Data are presented below:

Serum albendazole sulphoxide levels (mg/ml) per patient
Gp A (albendazole 10 mg/kg/day)
Mean=50.34 (n=17)
Gp B (albendazole 20 mg/kg/day)
Mean=38.35 (n=10)
Gp C (albendazole 10 mg/kg/day
+ praziquantel 25 mg/kg/day)
Mean=32.66 (n=20)
  1. Draw boxplots and assess shape of distributions

    We first examine box plots to assess whether a parametric or non-parametric ANOVA would be more appropriate.

    {Fig. 1a}

    The plot of the raw data strongly suggests that distributions are non-normal (at least for B and C) and variances are not homogeneous. However, a log transformation appears to make distributions more symmetrical and variances more similar. Hence the most powerful approach to analyzing these data would be to 1. test homogeneity of variances before and after a log transformation, and 2. if the transformation successfully stabilized variances , carry out a parametric ANOVA, and report results with geometric means.

    An alternative approach (which we will do here) is to analyze the data with Kruskal-Wallis ANOVA - but bear in mind that heterogeneous variances will make interpretation of the result more complex. Note that a log transformation would have no effect at all on the value of the Kruskal-Wallis statistic.

  2. Pool groups and rank observations

    We can do this quickly using R.

    Serum albendazole sulphoxide levels (mg/ml) per patient Sum of
    Gp A (albendazole 10 mg/kg/day)
    Mean=50.34 (n=17)
    Gp B (albendazole 20 mg/kg/day)
    Mean=38.35 (n=10)
    Gp C (albendazole 10 mg/kg/day
    + praziquantel 25 mg/kg/day)
    Mean=32.66 (n=20)

    Note we have also worked out the sum of ranks (Si) for each group.

  3. Calculate the Kruskal-Wallis statistic

    We will first calculate the statistic uncorrected for ties.

    K  =  [ 12 ( 332.52 + 1742 + 621.52 ) ] 3(47 + 1)
    47(47 + 1) 17 10 20
         =    9.42568


    Correcting for ties, we have six groups of ties producing mean ranks of 5.5 (2 ties),7.5 (2 ties),11 (3 ties),14.5 (2 ties),18.5 (2 ties) and 23 (3 ties). Hence the correction factor is given by:

    C    =    1 6 + 6 + 24 + 6 + 6 + 24)    =    0.999306
    47 3 − 47

    The corrected value of K is given by:

    K = 9.42568 / 0.999306 = 9.4322

    The P-value for this value can be obtained from the chi square distribution (df=2) . It is 0.00895 so we accept there is a highly significant difference between the groups.

  4. Compare groups

    As we pointed out above, how we interpret this difference is complicated by the differences between the variances. Ideally we would use the Fligner-Policello robust-rank order test - but even this is not appropriate in this instance becase it requires symmetrical distributions. Instead we will use the non-parametric equivalent of Tukey's honestly significant difference test for unequal numbers of replicates (Dunn's test) and accept that the test may be too liberal. For this we need to compute mean ranks (rather than sum of ranks) for each group by simply dividing the sum of ranks (Si) by the number of observations (ni).

    GroupnMeanMedianSum of ranksMean rank
    Gp B100.26200.22517417.40
    Gp A170.30350.290332.519.56
    Gp C200.67600.510621.531.08

    The standard errors for comparing each pair of groups are:

    SEB vs C    =       =   5.3104
    47 (48) ( 1 + 1 )
    12 10 20
    SEB vs A    =       =   5.4643
    47 (48) ( 1 + 1 )
    12 10 17
    SEA vs C    =       =   4.5710
    47 (48) ( 1 + 1 )
    12 17 20

    Honestly significant differences and actual differences in mean rank (from table above) are therefore:
    HSDB vs C = 2.394 5.3104 = 12.71     Actual difference = 13.68*
    HSDB vs A = 1.960 5.4643 = 10.71     Actual difference = 2.16ns
    HSDA vs C = 1.960 4.5710 =   8.96     Actual difference = 11.52*

  5. Conclusions

    The actual differences between levels in groups C and A, and between groups C and B were markedly larger than the honestly significant differences. We therefore accept these differences were unlikely to have arisen by chance. There was also a big difference in variability, with levels in groups C much more variable. Differences in variability are commonly ignored - but they could have important clinical implications (for example very high levels may be toxic). The obseved differences between groups may have resulted from the different treatment regimens - but since allocation was consecutive (not random), they may also have resulted from changes in protocols or in patients over time.