
Last chance! 50% off unlimited learning
Sale ends in
Performs the Ansari-Bradley two-sample test for a difference in scale parameters.
ansari.test(x, …)# S3 method for default
ansari.test(x, y,
alternative = c("two.sided", "less", "greater"),
exact = NULL, conf.int = FALSE, conf.level = 0.95,
…)
# S3 method for formula
ansari.test(formula, data, subset, na.action, …)
numeric vector of data values.
numeric vector of data values.
indicates the alternative hypothesis and must be
one of "two.sided"
, "greater"
or "less"
. You
can specify just the initial letter.
a logical indicating whether an exact p-value should be computed.
a logical,indicating whether a confidence interval should be computed.
confidence level of the interval.
a formula of the form lhs ~ rhs
where lhs
is a numeric variable giving the data values and rhs
a factor
with two levels giving the corresponding groups.
an optional matrix or data frame (or similar: see
model.frame
) containing the variables in the
formula formula
. By default the variables are taken from
environment(formula)
.
an optional vector specifying a subset of observations to be used.
a function which indicates what should happen when
the data contain NA
s. Defaults to
getOption("na.action")
.
further arguments to be passed to or from methods.
A list with class "htest"
containing the following components:
the value of the Ansari-Bradley test statistic.
the p-value of the test.
the ratio of scales
a character string describing the alternative hypothesis.
the string "Ansari-Bradley test"
.
a character string giving the names of the data.
a confidence interval for the scale parameter.
(Only present if argument conf.int = TRUE
.)
an estimate of the ratio of scales.
(Only present if argument conf.int = TRUE
.)
Suppose that x
and y
are independent samples from
distributions with densities x
has a larger
variance, "greater"
) or "less"
).
By default (if exact
is not specified), an exact p-value
is computed if both samples contain less than 50 finite values and
there are no ties. Otherwise, a normal approximation is used.
Optionally, a nonparametric confidence interval and an estimator for
Note that mid-ranks are used in the case of ties rather than average scores as employed in Hollander & Wolfe (1973). See, e.g., Hajek, Sidak and Sen (1999), pages 131ff, for more information.
David F. Bauer (1972). Constructing confidence sets using rank statistics. Journal of the American Statistical Association, 67, 687--690. 10.1080/01621459.1972.10481279.
Jaroslav Hajek, Zbynek Sidak and Pranab K. Sen (1999). Theory of Rank Tests. San Diego, London: Academic Press.
Myles Hollander and Douglas A. Wolfe (1973). Nonparametric Statistical Methods. New York: John Wiley & Sons. Pages 83--92.
fligner.test
for a rank-based (nonparametric)
mood.test
for another rank-based two-sample test for a
difference in scale parameters;
var.test
and bartlett.test
for parametric
tests for the homogeneity in variance.
ansari_test
in package coin
for exact and approximate conditional p-values for the
Ansari-Bradley test, as well as different methods for handling ties.
# NOT RUN {
## Hollander & Wolfe (1973, p. 86f):
## Serum iron determination using Hyland control sera
ramsay <- c(111, 107, 100, 99, 102, 106, 109, 108, 104, 99,
101, 96, 97, 102, 107, 113, 116, 113, 110, 98)
jung.parekh <- c(107, 108, 106, 98, 105, 103, 110, 105, 104,
100, 96, 108, 103, 104, 114, 114, 113, 108, 106, 99)
ansari.test(ramsay, jung.parekh)
ansari.test(rnorm(10), rnorm(10, 0, 2), conf.int = TRUE)
## try more points - failed in 2.4.1
ansari.test(rnorm(100), rnorm(100, 0, 2), conf.int = TRUE)
# }
Run the code above in your browser using DataLab