Learn R Programming

Sim.DiffProc (version 2.1)

Kern_meth: Kernel Density of Random Variable X

Description

kernel density estimates. Its default method does so with the given kernel and bandwidth for univariate observations.

Usage

Kern_meth(X, bw, k)

Arguments

X
a numeric vector of the observed values.
bw
the smoothing bandwidth to be used. The kernels are scaled such that this is the standard deviation of the smoothing kernel. bw=c('Irt','scott','Ucv','Bcv','SJ') or manual, see details bw.nrd0
k
a character string giving the smoothing kernel to be used. This must be one of "gaussian", "rectangular", "triangular", "epanechnikov", "biweight", "cosine" or "optcosine"

Value

  • plot.density for your data.

Details

see details plot.density

See Also

hist_meth Histograms,fctrep_Meth Empirical Distribution.

Examples

Run this code
## Example 1
## fixed bw with different kernel
X <- rbeta(1000,1,2)
par(mfrow=c(2,2))
Kern_meth(X, bw='Ucv', k="rectangular")
Kern_meth(X, bw='Ucv',k="triangular")
Kern_meth(X, bw='Ucv',k="epanechnikov")
Kern_meth(X, bw='Ucv',k="cosine")

## Example 2
## fixed kernel with different bw
Y <- rlnorm(1000)
par(mfrow=c(2,2))
Kern_meth(Y, bw='Irt', k="epanechnikov")
Kern_meth(Y, bw='Ucv',k="epanechnikov")
Kern_meth(Y, bw='scott',k="epanechnikov")
Kern_meth(Y, bw=0.4,k="epanechnikov")

Run the code above in your browser using DataLab