Kruskal-Wallis test
Overview
The Kruskal-Wallis test is a non-parametric test used for testing whether samples originate from the same distribution. The parametric equivalent of the Kruskal-Wallis test is the one-way analysis of variance (ANOVA). When rejecting the null hypothesis of the Kruskal-Wallis test, then at least one sample stochastically dominates at least one other sample. The test does not identify where this stochastic dominance occurs or for how many pairs of groups stochastic dominance obtains. The null hypothesis states that all months (or quarters, respectively) have the same mean. Under this hypothesis the test statistic follows a distribution. When this hypothesis is rejected, it is assumed that time series values differ significantly between periods and the test results are displayed in green
The test is typically applied to groups of data . Each group is composed of observations, which are indexed by . Each month (or quarter) groups all the observations available for a certain number of years.
As opposed to the notation used in the Friedman test, number of observations here is not necessarily equal for each group. The ranking of each data point, represented by variable ., is now defined different than in Friedman test, since it considers all observables , thereby ignoring group membership.
The test statistic is given by
where and
- is the number of observations in group
- is the average of the absolute ranks of the data in group
- The average rank is
Under the null hypothesis that all groups are generated from the same distribution, the test statistic Q is approximated by a chi-squared distribution. Thus, the p-value is given by . This approximation can be misleading if some of the groups are very small (i.e. less than five elements). If the statistic is not significant, then there is no evidence of stochastic dominance between the samples. However, if the test is significant then at least one sample stochastically dominates another sample.
Use
The test can be applied directly to any series by selecting the option Statistical Methods » Seasonal Adjustment » Tools » Seasonality Tests. This is an example of how results are displayed for the case of a monthly series:
The test can be applied to the input series before any seasonal adjustment method has been applied. It can also be applied to the seasonally adjusted series or to the irreguar component.
Implementation
This test is implemented in the class ec.satoolkit.diagnostics.KruskallWallisTest
References
- Kruskal; Wallis (1952). “Use of ranks in one-criterion variance analysis”. Journal of the American Statistical Association 47 (260): 583–621. doi:10.1080/01621459.1952.10483441.