EVOLUTION-MANAGER
Edit File: ansari.test.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Ansari-Bradley Test</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for ansari.test {stats}"><tr><td>ansari.test {stats}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Ansari-Bradley Test</h2> <h3>Description</h3> <p>Performs the Ansari-Bradley two-sample test for a difference in scale parameters. </p> <h3>Usage</h3> <pre> ansari.test(x, ...) ## Default S3 method: ansari.test(x, y, alternative = c("two.sided", "less", "greater"), exact = NULL, conf.int = FALSE, conf.level = 0.95, ...) ## S3 method for class 'formula' ansari.test(formula, data, subset, na.action, ...) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x</code></td> <td> <p>numeric vector of data values.</p> </td></tr> <tr valign="top"><td><code>y</code></td> <td> <p>numeric vector of data values.</p> </td></tr> <tr valign="top"><td><code>alternative</code></td> <td> <p>indicates the alternative hypothesis and must be one of <code>"two.sided"</code>, <code>"greater"</code> or <code>"less"</code>. You can specify just the initial letter.</p> </td></tr> <tr valign="top"><td><code>exact</code></td> <td> <p>a logical indicating whether an exact p-value should be computed.</p> </td></tr> <tr valign="top"><td><code>conf.int</code></td> <td> <p>a logical,indicating whether a confidence interval should be computed.</p> </td></tr> <tr valign="top"><td><code>conf.level</code></td> <td> <p>confidence level of the interval.</p> </td></tr> <tr valign="top"><td><code>formula</code></td> <td> <p>a formula of the form <code>lhs ~ rhs</code> where <code>lhs</code> is a numeric variable giving the data values and <code>rhs</code> a factor with two levels giving the corresponding groups.</p> </td></tr> <tr valign="top"><td><code>data</code></td> <td> <p>an optional matrix or data frame (or similar: see <code><a href="model.frame.html">model.frame</a></code>) containing the variables in the formula <code>formula</code>. By default the variables are taken from <code>environment(formula)</code>.</p> </td></tr> <tr valign="top"><td><code>subset</code></td> <td> <p>an optional vector specifying a subset of observations to be used.</p> </td></tr> <tr valign="top"><td><code>na.action</code></td> <td> <p>a function which indicates what should happen when the data contain <code>NA</code>s. Defaults to <code>getOption("na.action")</code>.</p> </td></tr> <tr valign="top"><td><code>...</code></td> <td> <p>further arguments to be passed to or from methods.</p> </td></tr> </table> <h3>Details</h3> <p>Suppose that <code>x</code> and <code>y</code> are independent samples from distributions with densities <i>f((t-m)/s)/s</i> and <i>f(t-m)</i>, respectively, where <i>m</i> is an unknown nuisance parameter and <i>s</i>, the ratio of scales, is the parameter of interest. The Ansari-Bradley test is used for testing the null that <i>s</i> equals 1, the two-sided alternative being that <i>s != 1</i> (the distributions differ only in variance), and the one-sided alternatives being <i>s > 1</i> (the distribution underlying <code>x</code> has a larger variance, <code>"greater"</code>) or <i>s < 1</i> (<code>"less"</code>). </p> <p>By default (if <code>exact</code> 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. </p> <p>Optionally, a nonparametric confidence interval and an estimator for <i>s</i> 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. </p> <p>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. </p> <h3>Value</h3> <p>A list with class <code>"htest"</code> containing the following components: </p> <table summary="R valueblock"> <tr valign="top"><td><code>statistic</code></td> <td> <p>the value of the Ansari-Bradley test statistic.</p> </td></tr> <tr valign="top"><td><code>p.value</code></td> <td> <p>the p-value of the test.</p> </td></tr> <tr valign="top"><td><code>null.value</code></td> <td> <p>the ratio of scales <i>s</i> under the null, 1.</p> </td></tr> <tr valign="top"><td><code>alternative</code></td> <td> <p>a character string describing the alternative hypothesis.</p> </td></tr> <tr valign="top"><td><code>method</code></td> <td> <p>the string <code>"Ansari-Bradley test"</code>.</p> </td></tr> <tr valign="top"><td><code>data.name</code></td> <td> <p>a character string giving the names of the data.</p> </td></tr> <tr valign="top"><td><code>conf.int</code></td> <td> <p>a confidence interval for the scale parameter. (Only present if argument <code>conf.int = TRUE</code>.)</p> </td></tr> <tr valign="top"><td><code>estimate</code></td> <td> <p>an estimate of the ratio of scales. (Only present if argument <code>conf.int = TRUE</code>.)</p> </td></tr> </table> <h3>Note</h3> <p>To compare results of the Ansari-Bradley test to those of the F test to compare two variances (under the assumption of normality), observe that <i>s</i> is the ratio of scales and hence <i>s^2</i> is the ratio of variances (provided they exist), whereas for the F test the ratio of variances itself is the parameter of interest. In particular, confidence intervals are for <i>s</i> in the Ansari-Bradley test but for <i>s^2</i> in the F test. </p> <h3>References</h3> <p>David F. Bauer (1972). Constructing confidence sets using rank statistics. <em>Journal of the American Statistical Association</em>, <b>67</b>, 687–690. doi: <a href="https://doi.org/10.1080/01621459.1972.10481279">10.1080/01621459.1972.10481279</a>. </p> <p>Jaroslav Hajek, Zbynek Sidak and Pranab K. Sen (1999). <em>Theory of Rank Tests</em>. San Diego, London: Academic Press. </p> <p>Myles Hollander and Douglas A. Wolfe (1973). <em>Nonparametric Statistical Methods</em>. New York: John Wiley & Sons. Pages 83–92. </p> <h3>See Also</h3> <p><code><a href="fligner.test.html">fligner.test</a></code> for a rank-based (nonparametric) <i>k</i>-sample test for homogeneity of variances; <code><a href="mood.test.html">mood.test</a></code> for another rank-based two-sample test for a difference in scale parameters; <code><a href="var.test.html">var.test</a></code> and <code><a href="bartlett.test.html">bartlett.test</a></code> for parametric tests for the homogeneity in variance. </p> <p><code><a href="../../coin/html/ScaleTests.html">ansari_test</a></code> in package <a href="https://CRAN.R-project.org/package=coin"><span class="pkg">coin</span></a> for exact and approximate <em>conditional</em> p-values for the Ansari-Bradley test, as well as different methods for handling ties. </p> <h3>Examples</h3> <pre> ## 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) </pre> <hr /><div style="text-align: center;">[Package <em>stats</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>