| bkde {KernSmooth} | R Documentation |
Compute a Binned Kernel Density Estimate
Description
Returns x and y coordinates of the binned kernel density estimate of the probability density of the data.
Usage
bkde(x, kernel = "normal", canonical = FALSE, bandwidth,
gridsize = 401L, range.x, truncate = TRUE)
Arguments
x |
numeric vector of observations from the distribution whose density is to be estimated. Missing values are not allowed. |
bandwidth |
the kernel bandwidth smoothing parameter. Larger values of
|
kernel |
character string which determines the smoothing kernel.
|
canonical |
length-one logical vector: if |
gridsize |
the number of equally spaced points at which to estimate the density. |
range.x |
vector containing the minimum and maximum values of |
truncate |
logical flag: if |
Details
This is the binned approximation to the ordinary kernel density estimate.
Linear binning is used to obtain the bin counts.
For each x value in the sample, the kernel is
centered on that x and the heights of the kernel at each datapoint are summed.
This sum, after a normalization, is the corresponding y value in the output.
Value
a list containing the following components:
x |
vector of sorted |
y |
vector of density estimates
at the corresponding |
Background
Density estimation is a smoothing operation. Inevitably there is a trade-off between bias in the estimate and the estimate's variability: large bandwidths will produce smooth estimates that may hide local features of the density; small bandwidths may introduce spurious bumps into the estimate.
References
Wand, M. P. and Jones, M. C. (1995). Kernel Smoothing. Chapman and Hall, London.
See Also
density, dpik, hist,
ksmooth.
Examples
data(geyser, package="MASS")
x <- geyser$duration
est <- bkde(x, bandwidth=0.25)
plot(est, type="l")