Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

akj

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)
 }

quantreg

Quantile Regression

v5.85
GPL (>= 2)
Authors
Roger Koenker [cre, aut], Stephen Portnoy [ctb] (Contributions to Censored QR code), Pin Tian Ng [ctb] (Contributions to Sparse QR code), Blaise Melly [ctb] (Contributions to preprocessing code), Achim Zeileis [ctb] (Contributions to dynrq code essentially identical to his dynlm code), Philip Grosjean [ctb] (Contributions to nlrq code), Cleve Moler [ctb] (author of several linpack routines), Yousef Saad [ctb] (author of sparskit2), Victor Chernozhukov [ctb] (contributions to extreme value inference code), Ivan Fernandez-Val [ctb] (contributions to extreme value inference code), Brian D Ripley [trl, ctb] (Initial (2001) R port from S (to my everlasting shame -- how could I have been so slow to adopt R!) and for numerous other suggestions and useful advice)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.