wkdecontour: Contour plot of a bivariate weighted kernel density estimate

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

Description

Produces a contour plot of a bivariate weighted kernel density estimate

Usage

1
2
3
4
wkde.contour(y, Sigma, H, w, gamma,
             RUG = TRUE, COMPARE = TRUE, LEVELS = NA,
             XLAB = expression(italic(x)), YLAB = expression(italic(y)),
             DL = FALSE)

Arguments

y

the observed values; matrix with two columns.

Sigma

the variance-covariance matrix of the contaminating (normal) distribution.

H

the matrix of smoothing parameters to be used for the weighted bivariate kernel density estimate; if missing the bandwidth returned by Hpi(y,) will be used.

w

the weights to be used; if missing the weights returned by w.hat.mv(y, Sigma, H, gamma = gamma) will be used.

gamma

the regularisation parameter to be used

RUG

logical; if TRUE points are added to the plot indicating the location of the observed value with the size of the points being proportional to the weight attached to each observation.

COMPARE

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

LEVELS

passed to the argument levels of contour.

XLAB

passed as argument xlab to contour.

YLAB

passed as argument ylab to contour.

DL

passed to the argument drawlabs of contour.

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.2d, w.hat.mv, Hpi

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
  ##
  ## Figure 7 from paper
  ##
  library(ks)
  Age <- framingham[,2]
  Age.lim.2 <- 56
  SBP1.A <- framingham[Age>=Age.lim.2,3] # SBP, measure 1, Exam 2 
  SBP2.A <- framingham[Age>=Age.lim.2,4] # SBP, measure 2, Exam 2 
  SBP1.B <- framingham[Age>=Age.lim.2,5] # SBP, measure 1, Exam 3 
  SBP2.B <- framingham[Age>=Age.lim.2,6] # SBP, measure 2, Exam 3 
  sigma.fram.A <- sd(SBP1.A-SBP2.A)
  sigma.fram.B <- sd(SBP1.B-SBP2.B)
  Sigma.fram <- diag(c(sigma.fram.A,sigma.fram.B))^2
  SBP.A <- SBP1.A
  SBP.B <- SBP1.B
  SBP.bi <- cbind(SBP.A,SBP.B)
  H.fram <- Hpi(SBP.bi)

  par(mfrow=c(1,2))
  wkde.contour(SBP.bi, Sigma=diag(c(0,0)), H=H.fram,
               RUG=FALSE, COMPARE=FALSE, XLAB="SBP2", YLAB="SBP3",
               LEVELS=seq(5e-5,40e-5,by=10e-5))
  points(SBP.A,SBP.B,pch=19,cex=0.25)

  gamma <- 0.4
  wkde.contour(SBP.bi, Sigma=Sigma.fram, H=H.fram,
               RUG=FALSE, COMPARE=FALSE, XLAB="SBP2", YLAB="SBP3",
               LEVELS=seq(5e-5,40e-5,by=10e-5), gamma=gamma)
  points(SBP.A,SBP.B,pch=19,cex=0.25)

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