EVOLUTION-MANAGER
Edit File: mad.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: Median Absolute Deviation</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 mad {stats}"><tr><td>mad {stats}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Median Absolute Deviation</h2> <h3>Description</h3> <p>Compute the median absolute deviation, i.e., the (lo-/hi-) median of the absolute deviations from the median, and (by default) adjust by a factor for asymptotically normal consistency. </p> <h3>Usage</h3> <pre> mad(x, center = median(x), constant = 1.4826, na.rm = FALSE, low = FALSE, high = FALSE) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x</code></td> <td> <p>a numeric vector.</p> </td></tr> <tr valign="top"><td><code>center</code></td> <td> <p>Optionally, the centre: defaults to the median.</p> </td></tr> <tr valign="top"><td><code>constant</code></td> <td> <p>scale factor.</p> </td></tr> <tr valign="top"><td><code>na.rm</code></td> <td> <p>if <code>TRUE</code> then <code>NA</code> values are stripped from <code>x</code> before computation takes place.</p> </td></tr> <tr valign="top"><td><code>low</code></td> <td> <p>if <code>TRUE</code>, compute the ‘lo-median’, i.e., for even sample size, do not average the two middle values, but take the smaller one.</p> </td></tr> <tr valign="top"><td><code>high</code></td> <td> <p>if <code>TRUE</code>, compute the ‘hi-median’, i.e., take the larger of the two middle values for even sample size.</p> </td></tr> </table> <h3>Details</h3> <p>The actual value calculated is <code>constant * cMedian(abs(x - center))</code> with the default value of <code>center</code> being <code>median(x)</code>, and <code>cMedian</code> being the usual, the ‘low’ or ‘high’ median, see the arguments description for <code>low</code> and <code>high</code> above. </p> <p>The default <code>constant = 1.4826</code> (approximately <i>1/ Φ^(-1)(3/4)</i> = <code>1/qnorm(3/4)</code>) ensures consistency, i.e., </p> <p style="text-align: center;"><i>E[mad(X_1,…,X_n)] = σ</i></p> <p>for <i>X_i</i> distributed as <i>N(μ, σ^2)</i> and large <i>n</i>. </p> <p>If <code>na.rm</code> is <code>TRUE</code> then <code>NA</code> values are stripped from <code>x</code> before computation takes place. If this is not done then an <code>NA</code> value in <code>x</code> will cause <code>mad</code> to return <code>NA</code>. </p> <h3>See Also</h3> <p><code><a href="IQR.html">IQR</a></code> which is simpler but less robust, <code><a href="median.html">median</a></code>, <code><a href="cor.html">var</a></code>. </p> <h3>Examples</h3> <pre> mad(c(1:9)) print(mad(c(1:9), constant = 1)) == mad(c(1:8, 100), constant = 1) # = 2 ; TRUE x <- c(1,2,3,5,7,8) sort(abs(x - median(x))) c(mad(x, constant = 1), mad(x, constant = 1, low = TRUE), mad(x, constant = 1, high = 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>