## Kruskal-Wallis Demo

The following data represent 4 groups of measurements of a single factor. Note that not all waves have the same length. The Kruskal-Wallis test is a non-parametric test that uses ranks of the data to test the null hypothesis that there is no difference among groups.

wave1 | wave2 | wave3 | wave4 |

5.1 | 6.3 | 5.5 | 5.2 |

6.7 | 5 | 5.6 | 5.8 |

6 | 3.9 | 6.7 | 6.2 |

6.2 | 6.2 | 5.3 | 6 |

5.6 | 6.1 | 5.3 | 7 |

6.3 | 4.3 | 6.7 | 6.3 |

5.5 | 7.6 | 8.3 |

To run the test execute the following command:

StatsKWTest /T=1/Q wave1,wave2,wave3,wave4

The results are displayed in the Kruskal-Wallis Test table:

Num_Groups | 4 |

Num_Valid_Data | 27 |

Alpha | 0.05 |

H | 2.93763 |

Hc_Chi_square_approx | 7.81473 |

P_Chi_square_approx | 0.401342 |

Hc_Wallace_approx | 7.81984 |

P_Wallace_approx | 0.411107 |

The H statistic is clearly below the critical value so H_{0} (data in the input waves are
the same) is accepted.

The following wave represents a 5th group of data for the same factor:

wave5 |

6.7 |

7.3 |

7 |

6.7 |

7.2 |

7.1 |

7.2 |

To run the test execute the following command:

StatsKWTest /T=1/Q wave1,wave2,wave3,wave5

The results are displayed in the Kruskal-Wallis Test table:

Num_Groups | 4 |

Num_Valid_Data | 27 |

Alpha | 0.05 |

H | 12.677 |

Hc_Chi_square_approx | 7.81473 |

P_Chi_square_approx | 0.00538994 |

Hc_Wallace_approx | 7.81984 |

P_Wallace_approx | 0.00283628 |

In this case the statistic H clearly indicates that H_{0} should be rejected but there is
no indication that the variation is mostly due to wave5. To perform a multi-comparison test execute the following command:

The results are shown in the NP Multiple Comparison (DHW) table:StatsNPMCTest/T=1/DHW/Q wave1,wave2,wave3,wave5

Diff | SE | Q | Qc | Conclusion | |

wave5_vs_wave2 | 14.7381 | 4.39832 | 3.35084 | 2.63826 | 0 |

wave5_vs_wave1 | 11.1429 | 4.22577 | 2.63688 | 2.63826 | 1 |

wave5_vs_wave3 | 9.28571 | 4.22577 | 2.1974 | 2.63826 | 1 |

wave3_vs_wave2 | 5.45238 | 4.39832 | 1.23965 | 2.63826 | 1 |

wave3_vs_wave1 | 1.85714 | 4.22577 | 0.43948 | 2.63826 | 1 |

wave1_vs_wave2 | 3.59524 | 4.39832 | 0.817411 | 2.63826 | 1 |

Checking the Q statistic we see that most of the variation is between wave5 and the other waves with maximum difference between wave5 and wave2. Note that in the last operation we used the /DHW flag because the input waves were not of the same length.