kruskalwallis
statistics: p = kruskalwallis (x)
statistics: p = kruskalwallis (x, group)
statistics: p = kruskalwallis (x, group, displayopt)
statistics: p = kruskalwallis (x, group, displayopt, Name, Value)
statistics: [p, tbl] = kruskalwallis (x, …)
statistics: [p, tbl, stats] = kruskalwallis (x, …)
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:
NaN.
kruskalwallis can return up to three output arguments:
stats also holds the effect size of the test, an Octave extension:
EtaSquared, the rank eta squared
max (0, (H - k + 1) / (n - k)) for the statistic H over
k groups and n observations, which is the share of the
variance of the ranks the groups account for, corrected for bias, and
EtaSquaredCI, its two-sided confidence interval at the level
100 (1 - alpha) percent. By default the interval inverts the
noncentral chi-square distribution of H on k - 1 degrees of
freedom, taken as H’s distribution under the alternative, which it
is for large samples. Three options after displayopt, also an
Octave extension, set it:
| Name | Value |
|---|---|
'Alpha' | The significance level of the interval, a scalar between 0 and 1, 0.05 by default. |
'ConfidenceIntervalType' | 'exact', the default,
or 'bootstrap' for the bias-corrected and accelerated bootstrap
interval, resampling within each group. |
'NumBootstraps' | The number of bootstrap replicates, a positive integer, 1000 by default. |
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);
|
See also: anova1, friedman, ranksum, multcompare
Source Code: kruskalwallis
rng (42); x = meshgrid (1:6); x = x + normrnd (0, 1, 6, 6); kruskalwallis (x, [], 'off');
Kruskal-Wallis ANOVA Table Source SS df MS Chi-sq Prob>Chi-sq --------------------------------------------------------- Columns 2880.00 5 576.00 25.95 9.14160e-05 Error 1005.00 30 33.50 Total 3885.00 35
rng (42); x = meshgrid (1:6); x = x + normrnd (0, 1, 6, 6); [p, atab] = kruskalwallis (x);
Kruskal-Wallis ANOVA Table Source SS df MS Chi-sq Prob>Chi-sq --------------------------------------------------------- Columns 2880.00 5 576.00 25.95 9.14160e-05 Error 1005.00 30 33.50 Total 3885.00 35
rng (42);
x = ones (30, 4) .* [-2, 0, 1, 5];
x = x + normrnd (0, 2, 30, 4);
group = {'A', 'B', 'C', 'D'};
kruskalwallis (x, group);
Kruskal-Wallis ANOVA Table Source SS df MS Chi-sq Prob>Chi-sq --------------------------------------------------------- Columns 80690.60 3 26896.87 66.69 2.18551e-14 Error 63299.40 116 545.68 Total 143990.00 119