20.07.2013 Views

Bandwidth Selectors for Kernel Density Estimation

Bandwidth Selectors for Kernel Density Estimation

Bandwidth Selectors for Kernel Density Estimation

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

andwidth(stats) R Documentation<br />

<strong>Bandwidth</strong> <strong>Selectors</strong> <strong>for</strong> <strong>Kernel</strong> <strong>Density</strong> <strong>Estimation</strong><br />

Description<br />

<strong>Bandwidth</strong> selectors <strong>for</strong> gaussian windows in density.<br />

Usage<br />

bw.nrd0(x)<br />

bw.nrd(x)<br />

bw.ucv(x, nb = 1000, lower = 0.1 * hmax, upper = hmax)<br />

bw.bcv(x, nb = 1000, lower = 0.1 * hmax, upper = hmax)<br />

bw.SJ(x, nb = 1000, lower = 0.1 * hmax, upper = hmax,<br />

method = c("ste", "dpi"))<br />

Arguments<br />

x A data vector.<br />

nb number of bins to use.<br />

lower,<br />

upper<br />

Range over which to minimize. The default is almost always satisfactory. hmax is<br />

calculated internally from a normal reference bandwidth.<br />

method Either "ste" ("solve-the-equation") or "dpi" ("direct plug-in").<br />

Details<br />

bw.nrd0 implements a rule-of-thumb <strong>for</strong> choosing the bandwidth of a Gaussian kernel density<br />

estimator. It defaults to 0.9 times the minimum of the standard deviation and the interquartile<br />

range divided by 1.34 times the sample size to the negative one-fifth power (= Silverman's<br />

“rule of thumb”, Silverman (1986, page 48, eqn (3.31)) unless the quartiles coincide when a<br />

positive result will be guaranteed.<br />

bw.nrd is the more common variation given by Scott (1992), using factor 1.06.<br />

bw.ucv and bw.bcv implement unbiased and biased cross-validation respectively.<br />

bw.SJ implements the methods of Sheather & Jones (1991) to select the bandwidth using pilot<br />

estimation of derivatives.<br />

The algorithm solves an equation (via uniroot) and because of that, enlarges the interval<br />

c(lower,upper) when the boundaries were not user-specified and do not bracket the root.<br />

Value<br />

A bandwidth on a scale suitable <strong>for</strong> the bw argument of density.


References<br />

Scott, D. W. (1992) Multivariate <strong>Density</strong> <strong>Estimation</strong>: Theory, Practice, and Visualization.<br />

Wiley.<br />

Sheather, S. J. and Jones, M. C. (1991) A reliable data-based bandwidth selection method <strong>for</strong><br />

kernel density estimation. Journal of the Royal Statistical Society series B, 53, 683–690.<br />

Silverman, B. W. (1986) <strong>Density</strong> <strong>Estimation</strong>. London: Chapman and Hall.<br />

Venables, W. N. and Ripley, B. D. (2002) Modern Applied Statistics with S. Springer.<br />

See Also<br />

density.<br />

bandwidth.nrd, ucv, bcv and width.SJ in package MASS, which are all scaled to the width<br />

argument of density and so give answers four times as large.<br />

Examples<br />

plot(density(precip, n = 1000))<br />

rug(precip)<br />

lines(density(precip, bw="nrd"), col = 2)<br />

lines(density(precip, bw="ucv"), col = 3)<br />

lines(density(precip, bw="bcv"), col = 4)<br />

lines(density(precip, bw="SJ-ste"), col = 5)<br />

lines(density(precip, bw="SJ-dpi"), col = 6)<br />

legend(55, 0.035,<br />

legend = c("nrd0", "nrd", "ucv", "bcv", "SJ-ste", "SJ-dpi"),<br />

col = 1:6, lty = 1)<br />

[Package stats version 2.5.1 Index]

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!