1\name{akj} 2\alias{akj} 3\title{Density Estimation using Adaptive Kernel method} 4\description{ 5 Univariate \emph{adaptive} kernel density estimation a la Silverman. 6 As used by Portnoy and Koenker (1989). 7} 8\usage{ 9akj(x, z =, p =, h = -1, alpha = 0.5, kappa = 0.9, iker1 = 0) 10} 11\arguments{ 12 \item{x}{points used for centers of kernel assumed to be sorted.} 13 \item{z}{points at which density is calculated; defaults to an 14 equispaced sequence covering the range of x.} 15 \item{p}{vector of probabilities associated with \code{x}s; defaults 16 to 1/n for each x.} 17 \item{h}{initial window size (overall); defaults to Silverman's normal 18 reference.} 19 \item{alpha}{a sensitivity parameter that determines the sensitivity of 20 the local bandwidth to variations in the pilot density; defaults to .5.} 21 \item{kappa}{constant multiplier for initial (default) window width} 22 \item{iker1}{integer kernel indicator: 0 for normal kernel (default) 23 while 1 for Cauchy kernel (\code{\link{dcauchy}}).} 24} 25\value{ 26 a \code{\link{list}} structure is with components 27 \item{dens}{the vector of estimated density values \eqn{f(z)}} 28 \item{psi}{a vector of \eqn{\psi=-f'/f} function values.} 29 \item{score}{a vector of score \eqn{\psi' = (f'/f)^2 - f''/f} function 30 values.} 31 \item{h}{same as the input argument h} 32} 33\note{ 34 if the \code{score} function values are of interest, the Cauchy kernel 35 may be preferable. 36} 37\references{ 38 Portnoy, S and R Koenker, (1989) 39 Adaptive L Estimation of Linear Models; 40 \emph{Annals of Statistics} \bold{17}, 362--81. 41 42 Silverman, B. (1986) 43 \emph{Density Estimation}, pp 100--104. 44} 45\examples{ 46 set.seed(1) 47 x <- c(rnorm(600), 2 + 2*rnorm(400)) 48 xx <- seq(-5, 8, length=200) 49 z <- akj(x, xx) 50 plot(xx, z$dens, ylim=range(0,z$dens), type ="l", col=2) 51 abline(h=0, col="gray", lty=3) 52 plot(xx, z$psi, type ="l", col=2, main = expression(hat(psi(x)))) 53 plot(xx, z$score, type ="l", col=2, 54 main = expression("score " * hat(psi) * "'" * (x))) 55 56 if(require("nor1mix")) { 57 m3 <- norMix(mu= c(-4, 0, 3), sig2 = c(1/3^2, 1, 2^2), 58 w = c(.1,.5,.4)) 59 plot(m3, p.norm = FALSE) 60 set.seed(11) 61 x <- rnorMix(1000, m3) 62 z2 <- akj(x, xx) 63 lines(xx, z2$dens, col=2) 64 z3 <- akj(x, xx, kappa = 0.5, alpha = 0.88) 65 lines(xx, z3$dens, col=3) 66 } 67} 68\keyword{smooth} 69