EVOLUTION-MANAGER
Edit File: kruskal.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: Kruskal-Wallis Rank Sum 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 kruskal.test {stats}"><tr><td>kruskal.test {stats}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Kruskal-Wallis Rank Sum Test</h2> <h3>Description</h3> <p>Performs a Kruskal-Wallis rank sum test. </p> <h3>Usage</h3> <pre> kruskal.test(x, ...) ## Default S3 method: kruskal.test(x, g, ...) ## S3 method for class 'formula' kruskal.test(formula, data, subset, na.action, ...) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x</code></td> <td> <p>a numeric vector of data values, or a list of numeric data vectors. Non-numeric elements of a list will be coerced, with a warning.</p> </td></tr> <tr valign="top"><td><code>g</code></td> <td> <p>a vector or factor object giving the group for the corresponding elements of <code>x</code>. Ignored with a warning if <code>x</code> is a list.</p> </td></tr> <tr valign="top"><td><code>formula</code></td> <td> <p>a formula of the form <code>response ~ group</code> where <code>response</code> gives the data values and <code>group</code> a vector or factor of 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><code>kruskal.test</code> performs a Kruskal-Wallis rank sum test of the null that the location parameters of the distribution of <code>x</code> are the same in each group (sample). The alternative is that they differ in at least one. </p> <p>If <code>x</code> is a list, its elements are taken as the samples to be compared, and hence have to be numeric data vectors. In this case, <code>g</code> is ignored, and one can simply use <code>kruskal.test(x)</code> to perform the test. If the samples are not yet contained in a list, use <code>kruskal.test(list(x, ...))</code>. </p> <p>Otherwise, <code>x</code> must be a numeric data vector, and <code>g</code> must be a vector or factor object of the same length as <code>x</code> giving the group for the corresponding elements of <code>x</code>. </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 Kruskal-Wallis rank sum statistic.</p> </td></tr> <tr valign="top"><td><code>parameter</code></td> <td> <p>the degrees of freedom of the approximate chi-squared distribution of the 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>method</code></td> <td> <p>the character string <code>"Kruskal-Wallis rank sum 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> </table> <h3>References</h3> <p>Myles Hollander and Douglas A. Wolfe (1973), <em>Nonparametric Statistical Methods.</em> New York: John Wiley & Sons. Pages 115–120. </p> <h3>See Also</h3> <p>The Wilcoxon rank sum test (<code><a href="wilcox.test.html">wilcox.test</a></code>) as the special case for two samples; <code><a href="lm.html">lm</a></code> together with <code><a href="anova.html">anova</a></code> for performing one-way location analysis under normality assumptions; with Student's t test (<code><a href="t.test.html">t.test</a></code>) as the special case for two samples. </p> <p><code><a href="../../coin/html/LocationTests.html">wilcox_test</a></code> in package <a href="https://CRAN.R-project.org/package=coin"><span class="pkg">coin</span></a> for exact, asymptotic and Monte Carlo <em>conditional</em> p-values, including in the presence of ties. </p> <h3>Examples</h3> <pre> ## Hollander & Wolfe (1973), 116. ## Mucociliary efficiency from the rate of removal of dust in normal ## subjects, subjects with obstructive airway disease, and subjects ## with asbestosis. x <- c(2.9, 3.0, 2.5, 2.6, 3.2) # normal subjects y <- c(3.8, 2.7, 4.0, 2.4) # with obstructive airway disease z <- c(2.8, 3.4, 3.7, 2.2, 2.0) # with asbestosis kruskal.test(list(x, y, z)) ## Equivalently, x <- c(x, y, z) g <- factor(rep(1:3, c(5, 4, 5)), labels = c("Normal subjects", "Subjects with obstructive airway disease", "Subjects with asbestosis")) kruskal.test(x, g) ## Formula interface. require(graphics) boxplot(Ozone ~ Month, data = airquality) kruskal.test(Ozone ~ Month, data = airquality) </pre> <hr /><div style="text-align: center;">[Package <em>stats</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>