EVOLUTION-MANAGER
Edit File: bandwidth.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: Bandwidth Selectors for Kernel Density Estimation</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 bandwidth {stats}"><tr><td>bandwidth {stats}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Bandwidth Selectors for Kernel Density Estimation</h2> <h3>Description</h3> <p>Bandwidth selectors for Gaussian kernels in <code><a href="density.html">density</a></code>. </p> <h3>Usage</h3> <pre> bw.nrd0(x) bw.nrd(x) bw.ucv(x, nb = 1000, lower = 0.1 * hmax, upper = hmax, tol = 0.1 * lower) bw.bcv(x, nb = 1000, lower = 0.1 * hmax, upper = hmax, tol = 0.1 * lower) bw.SJ(x, nb = 1000, lower = 0.1 * hmax, upper = hmax, method = c("ste", "dpi"), tol = 0.1 * lower) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x</code></td> <td> <p>numeric vector.</p> </td></tr> <tr valign="top"><td><code>nb</code></td> <td> <p>number of bins to use.</p> </td></tr> <tr valign="top"><td><code>lower, upper</code></td> <td> <p>range over which to minimize. The default is almost always satisfactory. <code>hmax</code> is calculated internally from a normal reference bandwidth.</p> </td></tr> <tr valign="top"><td><code>method</code></td> <td> <p>either <code>"ste"</code> ("solve-the-equation") or <code>"dpi"</code> ("direct plug-in"). Can be abbreviated.</p> </td></tr> <tr valign="top"><td><code>tol</code></td> <td> <p>for method <code>"ste"</code>, the convergence tolerance for <code><a href="uniroot.html">uniroot</a></code>. The default leads to bandwidth estimates with only slightly more than one digit accuracy, which is sufficient for practical density estimation, but possibly not for theoretical simulation studies.</p> </td></tr> </table> <h3>Details</h3> <p><code>bw.nrd0</code> implements a rule-of-thumb for choosing the bandwidth of a Gaussian kernel density estimator. It defaults to 0.9 times the minimum of the standard deviation and the interquartile range divided by 1.34 times the sample size to the negative one-fifth power (= Silverman's ‘rule of thumb’, Silverman (1986, page 48, eqn (3.31))) <em>unless</em> the quartiles coincide when a positive result will be guaranteed. </p> <p><code>bw.nrd</code> is the more common variation given by Scott (1992), using factor 1.06. </p> <p><code>bw.ucv</code> and <code>bw.bcv</code> implement unbiased and biased cross-validation respectively. </p> <p><code>bw.SJ</code> implements the methods of Sheather & Jones (1991) to select the bandwidth using pilot estimation of derivatives.<br /> The algorithm for method <code>"ste"</code> solves an equation (via <code><a href="uniroot.html">uniroot</a></code>) and because of that, enlarges the interval <code>c(lower, upper)</code> when the boundaries were not user-specified and do not bracket the root. </p> <p>The last three methods use all pairwise binned distances: they are of complexity <i>O(n^2)</i> up to <code>n = nb/2</code> and <i>O(n)</i> thereafter. Because of the binning, the results differ slightly when <code>x</code> is translated or sign-flipped. </p> <h3>Value</h3> <p>A bandwidth on a scale suitable for the <code>bw</code> argument of <code>density</code>. </p> <h3>Note</h3> <p>Long vectors <code>x</code> are not supported, but neither are they by <code><a href="density.html">density</a></code> and kernel density estimation and for more than a few thousand points a histogram would be preferred. </p> <h3>Author(s)</h3> <p>B. D. Ripley, taken from early versions of package <span class="pkg">MASS</span>. </p> <h3>References</h3> <p>Scott, D. W. (1992) <em>Multivariate Density Estimation: Theory, Practice, and Visualization.</em> New York: Wiley. </p> <p>Sheather, S. J. and Jones, M. C. (1991). A reliable data-based bandwidth selection method for kernel density estimation. <em>Journal of the Royal Statistical Society series B</em>, <b>53</b>, 683–690. <a href="http://www.jstor.org/stable/2345597">http://www.jstor.org/stable/2345597</a>. </p> <p>Silverman, B. W. (1986). <em>Density Estimation</em>. London: Chapman and Hall. </p> <p>Venables, W. N. and Ripley, B. D. (2002). <em>Modern Applied Statistics with S</em>. Springer. </p> <h3>See Also</h3> <p><code><a href="density.html">density</a></code>. </p> <p><code><a href="../../MASS/html/bandwidth.nrd.html">bandwidth.nrd</a></code>, <code><a href="../../MASS/html/ucv.html">ucv</a></code>, <code><a href="../../MASS/html/bcv.html">bcv</a></code> and <code><a href="../../MASS/html/width.SJ.html">width.SJ</a></code> in package <a href="https://CRAN.R-project.org/package=MASS"><span class="pkg">MASS</span></a>, which are all scaled to the <code>width</code> argument of <code>density</code> and so give answers four times as large. </p> <h3>Examples</h3> <pre> require(graphics) plot(density(precip, n = 1000)) rug(precip) lines(density(precip, bw = "nrd"), col = 2) lines(density(precip, bw = "ucv"), col = 3) lines(density(precip, bw = "bcv"), col = 4) lines(density(precip, bw = "SJ-ste"), col = 5) lines(density(precip, bw = "SJ-dpi"), col = 6) legend(55, 0.035, legend = c("nrd0", "nrd", "ucv", "bcv", "SJ-ste", "SJ-dpi"), col = 1:6, lty = 1) </pre> <hr /><div style="text-align: center;">[Package <em>stats</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>