ansaribradley
statistics: h = ansaribradley (x, y)
statistics: h = ansaribradley (x, y, name, value)
statistics: [h, p] = ansaribradley (…)
statistics: [h, p, stats] = ansaribradley (…)
Ansari-Bradley two-sample test for equal dispersions.
h = ansaribradley (x, y) performs an Ansari-Bradley
test of the hypothesis that the two independent samples in the vectors
x and y come from distributions with the same dispersion
parameter, against the alternative that they come from distributions with
different dispersions. The result is h = 0 if the null hypothesis of
equal dispersions cannot be rejected at the 5% significance level, or
h = 1 if it can.
The Ansari-Bradley test is a nonparametric alternative to the two-sample
test (vartest2) that does not assume normality. It assumes
that the two samples are independent and that they come from distributions
with the same median and shape, differing (under the alternative) only in
dispersion. If the medians differ, the data should be recentred (e.g. by
subtracting the sample medians) before applying the test.
ansaribradley treats NaNs in x or y as missing values and
ignores them.
[h, p] = ansaribradley (…) returns the p-value of
the test, that is the probability, under the null hypothesis, of observing a
value of the test statistic as or more extreme than the one observed.
[h, p, stats] = ansaribradley (…) returns a
structure with the following fields:
W | the value of the Ansari-Bradley test statistic, the sum of the Ansari-Bradley scores of the sample x |
Wstar | the value of the approximate normal (z) statistic |
Source Code: ansaribradley
[…] = ansaribradley (…, name, value) specifies
one or more of the following name/value pairs:
| Name | Value |
|---|---|
'alpha' | the significance level. Default is 0.05. |
'tail' | a string specifying the alternative hypothesis |
'method' | a string selecting the p-value computation,
either 'exact' to use the exact permutation distribution of the
statistic, or 'approximate' to use the normal approximation. The
default is 'exact' when the total sample size is 25 or less, and
'approximate' otherwise. |
Source Code: ansaribradley
The 'tail' option can take one of the following values:
'both' | dispersions are not equal (two-tailed, default) |
'right' | dispersion of x is greater than dispersion of y (right-tailed) |
'left' | dispersion of x is less than dispersion of y (left-tailed) |
Source Code: ansaribradley
See also: vartest2, vartestn, kstest2, ranksum
Source Code: ansaribradley
Test whether two samples have the same dispersion. The second sample is drawn with twice the standard deviation, so the null hypothesis of equal dispersions should be rejected.
x = [42, 44, 38, 52, 48, 46, 40, 50]; y = [30, 62, 25, 70, 33, 58, 20, 65]; [h, p, stats] = ansaribradley (x, y)
h = 1
p = 1.5540e-04
stats =
scalar structure containing the fields:
W = 52
Wstar = 3.3806