wkdeplot: Plot a weighted kernel density estimate

Description Usage Arguments Details Value Author(s) References See Also Examples

Description

Function to plot a weighted kernel density estimate.

Usage

1
2
3
4
wkde.plot(y, eval, sigma, h, w, gamma, method = "exact",
          RUG = TRUE, COMPARE = TRUE,
          XLAB = expression(italic(x)), YLAB = "density",
          COL = 1:2, LTY = rep(1, 2), LWD = rep(1, 2), YLIM = NULL)

Arguments

y

the observed, contaminated data.

eval

grid on which the deconvolution density estimate be calculated.

sigma

the standard deviation of the contaminating (normal) distribution.

h

the bandwidth to be used for the weighted kernel density estimate

w

the weights to be used.

gamma

the regularisation parameter to be used; either a scalar for methods "exact" and "svm", or a vector of values from which a suitable value is selected via K-fold cross-validation for methods "exact.cv" and "svm.cv"

.

method

method to be used to solve the quadratic programming problem involved in calculating the weights; if "exact" or "exact.cv" then solveqp is used, otherwise ipop from the kernlab package is used.

RUG

logical; if TRUE a rug is added to the plot indicating the location of the observed value and the weight attached to each observation.

COMPARE

logical; if TRUE a kernel density estimate with all weights equal to one is added to the plot.

XLAB

label for the x axis.

YLAB

label for the y axis.

COL

colours in which the density estimates should be drawn.

LTY

line type in which the density estimates should be drawn.

LWD

line width with which the density estimates should be drawn.

YLIM

limits for the y axis.

Details

If "eval" is not specified, it defaults to seq(min(y)-0.1*sd(y), max(y)+0.1*sd(y), length=100).

If "w" is not specified, it defaults to w.hat(y, sigma=sigma, h=h, gamma=gamma, METHOD=method).

If "h" is not specified, it defaults to bw.SJ(y, method="dpi").

Value

Invisible NULL. This function is called for its side effect of creating a plot.

Author(s)

Martin L Hazelton m.hazelton@massey.ac.nz

Berwin A Turlach Berwin.Turlach@gmail.com

References

Hazelton, M.L. and Turlach, B.A. (2009). Nonparametric density deconvolution by weighted kernel estimators, Statistics and Computing 19(3): 217–228. http://dx.doi.org/10.1007/s11222-008-9086-7.

See Also

wkde, w.hat

Examples

1
2
3
4
5
  set.seed(100719)
  sig <- sqrt(29/40)  # Var(Z)/Var(X) = 0.1
  y <- rden(100, DEN=3, sigma=sig)
  wkde.plot(y, sigma=sig, gamma=2.05)
  wkde.plot(y, sigma=sig, gamma=4.4)

DeconWK documentation built on May 2, 2019, 6:08 p.m.