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, …)
"two.sided"
, "greater"
or "less"
. You
can specify just the initial letter.lhs ~ rhs
where lhs
is a numeric variable giving the data values and rhs
a factor
with two levels giving the corresponding groups.model.frame
) containing the variables in the
formula formula
. By default the variables are taken from
environment(formula)
.NA
s. Defaults to
getOption("na.action")
."htest"
containing the following components:
"Ansari-Bradley test"
.conf.int = TRUE
.)conf.int = TRUE
.)x
and y
are independent samples from
distributions with densities \(f((t-m)/s)/s\) and \(f(t-m)\),
respectively, where \(m\) is an unknown nuisance parameter and
\(s\), the ratio of scales, is the parameter of interest. The
Ansari-Bradley test is used for testing the null that \(s\) equals
1, the two-sided alternative being that \(s \ne 1\) (the
distributions differ only in variance), and the one-sided alternatives
being \(s > 1\) (the distribution underlying x
has a larger
variance, "greater"
) or \(s < 1\) ("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
\(s\) are computed. If exact p-values are available, an exact
confidence interval is obtained by the algorithm described in Bauer
(1972), and the Hodges-Lehmann estimator is employed. Otherwise, the
returned confidence interval and point estimate are based on normal
approximations. 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.fligner.test
for a rank-based (nonparametric)
\(k\)-sample test for homogeneity of variances;
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 https://CRAN.R-project.org/package=coin
for exact and approximate conditional p-values for the
Ansari-Bradley test, as well as different methods for handling ties.## 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