: [pval, k, df] = kruskal_wallis_test (x1, …)

Perform a Kruskal-Wallis one-factor analysis of variance.

Suppose a variable is observed for k > 1 different groups, and let x1, …, xk be the corresponding data vectors.

Under the null hypothesis that the ranks in the pooled sample are not affected by the group memberships, the test statistic k is approximately chi-square with df = k - 1 degrees of freedom.

If the data contains ties (some value appears more than once) k is divided by

1 - sum_ties / (n^3 - n)

where sum_ties is the sum of t^2 - t over each group of ties where t is the number of ties in the group and n is the total number of values in the input data. For more info on this adjustment see William H. Kruskal and W. Allen Wallis, Use of Ranks in One-Criterion Variance Analysis, Journal of the American Statistical Association, Vol. 47, No. 260 (Dec 1952).

The p-value (1 minus the CDF of this distribution at k) is returned in pval.

If no output argument is given, the p-value is displayed.

Package: statistics