akj {quantreg}R Documentation

Density Estimation using Adaptive Kernel method

Description

Univariate adaptive kernel density estimation a la Silverman. As used by Portnoy and Koenker (1989).

Usage

akj(x, z =, p =, h = -1, alpha = 0.5, kappa = 0.9, iker1 = 0)

Arguments

x

points used for centers of kernel assumed to be sorted.

z

points at which density is calculated; defaults to an equispaced sequence covering the range of x.

p

vector of probabilities associated with xs; defaults to 1/n for each x.

h

initial window size (overall); defaults to Silverman's normal reference.

alpha

a sensitivity parameter that determines the sensitivity of the local bandwidth to variations in the pilot density; defaults to .5.

kappa

constant multiplier for initial (default) window width

iker1

integer kernel indicator: 0 for normal kernel (default) while 1 for Cauchy kernel (dcauchy).

Value

a list structure is with components

dens

the vector of estimated density values f(z)

psi

a vector of ψ=-f'/f function values.

score

a vector of score ψ' = (f'/f)^2 - f''/f function values.

h

same as the input argument h

Note

if the score function values are of interest, the Cauchy kernel may be preferable.

References

Portnoy, S and R Koenker, (1989) Adaptive L Estimation of Linear Models; Annals of Statistics 17, 362–81.

Silverman, B. (1986) Density Estimation, pp 100–104.

Examples

 set.seed(1)
 x <- c(rnorm(600), 2 + 2*rnorm(400))
 xx <- seq(-5, 8, length=200)
 z <- akj(x, xx)
 plot(xx, z$dens, ylim=range(0,z$dens), type ="l", col=2)
 abline(h=0, col="gray", lty=3)
 plot(xx, z$psi, type ="l", col=2, main = expression(hat(psi(x))))
 plot(xx, z$score, type ="l", col=2,
      main = expression("score " * hat(psi) * "'" * (x)))

 if(require("nor1mix")) {
  m3 <- norMix(mu= c(-4, 0, 3), sig2 = c(1/3^2, 1, 2^2),
               w = c(.1,.5,.4))
  plot(m3, p.norm = FALSE)
  set.seed(11)
  x <- rnorMix(1000, m3)
  z2 <- akj(x, xx)
  lines(xx, z2$dens, col=2)
  z3 <- akj(x, xx, kappa = 0.5, alpha = 0.88)
  lines(xx, z3$dens, col=3)
 }

[Package quantreg version 5.34 Index]