Learn R Programming

asymmetry.measures (version 0.2)

kde: Kernel density estimator.

Description

Classical univariate kernel density estimator.

Usage

kde(xin, xout, h, kfun)

Arguments

xin

A vector of data points. Missing values not allowed.

xout

A vector of grid points at which the estimate will be calculated.

h

A scalar, the bandwidth to use in the estimate, e.g. bw.nrd(xin).

kfun

Kernel function to use.

Value

A vector with the density estimates at the designated points xout.

Details

Implements the classical density kernel estimator based on a sample \(X_1,X_2,.., X_n\) of i.i.d observations from a distribution \(F\) with density \(h\). The estimator is defined by

$$\hat{f}(x)= n^{-1}\sum_{i=1}^n K_h(x-X_{i}) $$ where \(h\) is determined by a bandwidth selector such as Silverman's default plug-in rule and \(K\), the kernel, is a non-negative probability density function.

References

Silverman, B.W. (1986), Density Estimation for Statistics and Data Analysis, Chapman and Hall, London.

See Also

bw.nrd, bw.nrd0, bw.ucv, bw.bcv

Examples

Run this code
# NOT RUN {
x.in <- rnorm(100)
x.out <- seq(-3.4,3.4,length=60)
bandwidth <- bw.nrd(x.in)
kernel <- Epanechnikov
dens.est <- kde(x.in,x.out,bandwidth,kernel)
plot(x.out,dens.est,col="red",main="Kernel density estimator")
# }

Run the code above in your browser using DataLab