Perform a Kruskal-Wallis test, the non-parametric alternative of a one-way analysis of variance (ANOVA), for comparing the means of two or more groups of data under the null hypothesis that the groups are drawn from the same population, i.e. the group means are equal.
kruskalwallis can take up to three input arguments:
kruskalwallis can return up to three output arguments:
If kruskalwallis is called without any output arguments, then it prints the results in a one-way ANOVA table to the standard output. It is also printed when displayopt is ’on’.
Examples:
x = meshgrid (1:6); x = x + normrnd (0, 1, 6, 6); [p, atab] = kruskalwallis(x);
x = ones (50, 4) .* [-2, 0, 1, 5]; x = x + normrnd (0, 2, 50, 4); group = {"A", "B", "C", "D"}; kruskalwallis (x, group);
The following code
x = meshgrid (1:6); x = x + normrnd (0, 1, 6, 6); kruskalwallis (x, [], 'off');
Produces the following output
Kruskal-Wallis ANOVA Table Source SS df MS Chi-sq Prob>Chi-sq --------------------------------------------------------- Columns 3256.33 5 651.27 29.34 1.99176e-05 Error 628.67 30 20.96 Total 3885.00 35
The following code
x = meshgrid (1:6); x = x + normrnd (0, 1, 6, 6); [p, atab] = kruskalwallis(x);
Produces the following output
Kruskal-Wallis ANOVA Table Source SS df MS Chi-sq Prob>Chi-sq --------------------------------------------------------- Columns 3211.00 5 642.20 28.93 2.39548e-05 Error 674.00 30 22.47 Total 3885.00 35
and the following figure
Figure 1 |
---|
The following code
x = ones (30, 4) .* [-2, 0, 1, 5]; x = x + normrnd (0, 2, 30, 4); group = {"A", "B", "C", "D"}; kruskalwallis (x, group);
Produces the following output
Kruskal-Wallis ANOVA Table Source SS df MS Chi-sq Prob>Chi-sq --------------------------------------------------------- Columns 92474.60 3 30824.87 76.43 2.22045e-16 Error 51515.40 116 444.10 Total 143990.00 119
and the following figure
Figure 1 |
---|
Package: statistics