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
bandwidth make smoother estimates, smaller values of
bandwidth make less smooth estimates. The default is a bandwidth
computed from the variance of x, specifically the
‘oversmoothed bandwidth selector’ of Wand and Jones
(1995, page 61).
kernel
character string which determines the smoothing kernel.
kernel can be:
"normal" - the Gaussian density function (the default).
"box" - a rectangular box.
"epanech" - the centred beta(2,2) density.
"biweight" - the centred beta(3,3) density.
"triweight" - the centred beta(4,4) density.
This can be abbreviated to any unique abbreviation.
canonical
logical flag: if TRUE, canonically scaled kernels are used.
gridsize
the number of equally spaced points at which to estimate
the density.
range.x
vector containing the minimum and maximum values of x
at which to compute the estimate.
The default is the minimum and maximum data values, extended by the
support of the kernel.
truncate
logical flag: if TRUE, data with x values outside the
range specified by range.x are ignored.
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 x values at which the estimate was computed.
y
vector of density estimates
at the corresponding x.
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")
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(KernSmooth)
KernSmooth 2.23 loaded
Copyright M. P. Wand 1997-2009
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/KernSmooth/bkde.Rd_%03d_medium.png", width=480, height=480)
> ### Name: bkde
> ### Title: Compute a Binned Kernel Density Estimate
> ### Aliases: bkde
> ### Keywords: distribution smooth
>
> ### ** Examples
>
> data(geyser, package="MASS")
> x <- geyser$duration
> est <- bkde(x, bandwidth=0.25)
> plot(est, type="l")
>
>
>
>
>
> dev.off()
null device
1
>