\HeaderA{dpik}{Select a Bandwidth for Kernel Density Estimation}{dpik}
\keyword{smooth}{dpik}
\begin{Description}\relax
Use direct plug-in methodology to select the bandwidth
of a kernel density estimate.
\end{Description}
\begin{Usage}
\begin{verbatim}
dpik(x, scalest="minim", level=2, kernel="normal",   
     canonical=FALSE, gridsize=401, range.x=range(x), 
     truncate=TRUE)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{x}] vector containing the sample on which the
kernel density estimate is to be constructed.

\item[\code{scalest}] estimate of scale.

\code{"stdev"} - standard deviation is used.

\code{"iqr"} - inter-quartile range divided by 1.349 is used.

\code{"minim"} - minimum of \code{"stdev"} and \code{"iqr"} is used.

\item[\code{level}] number of levels of functional estimation used in the
plug-in rule.

\item[\code{kernel}] character string which determines the smoothing kernel.
\code{kernel} can be:
\code{"normal"} - the Gaussian density function (the default).
\code{"box"} - a rectangular box.
\code{"epanech"} - the centred beta(2,2) density.
\code{"biweight"} - the centred beta(3,3) density.
\code{"triweight"} - the centred beta(4,4) density.

\item[\code{canonical}] logical flag: if \code{TRUE}, canonically scaled kernels are used

\item[\code{gridsize}] the number of equally-spaced points over which binning is 
performed to obtain kernel functional approximation. 

\item[\code{range.x}] vector containing the minimum and maximum values of \code{x}
at which to compute the estimate.
The default is the minimum and maximum data values.

\item[\code{truncate}] logical flag: if \code{TRUE}, data with \code{x} values outside the
range specified by \code{range.x} are ignored.

\end{ldescription}
\end{Arguments}
\begin{Details}\relax
The direct plug-in approach, where unknown functionals
that appear in expressions for the asymptotically
optimal bandwidths
are replaced by kernel estimates, is used.
The normal distribution is used to provide an
initial estimate.
\end{Details}
\begin{Value}
the selected bandwidth.
\end{Value}
\begin{Section}{Background}
This method for selecting the bandwidth of a kernel
density estimate was proposed by Sheather and
Jones (1991)
and is
described in Section 3.6 of Wand and Jones (1995).
\end{Section}
\begin{References}\relax
Sheather, S. J. and Jones, M. C. (1991).
A reliable data-based bandwidth selection method for
kernel density estimation.
\emph{Journal of the Royal Statistical Society, Series B},
\bold{53}, 683--690.

Wand, M. P. and Jones, M. C. (1995).
\emph{Kernel Smoothing.}
Chapman and Hall, London.
\end{References}
\begin{SeeAlso}\relax
\code{\LinkA{bkde}{bkde}}, \code{\LinkA{density}{density}}, \code{\LinkA{ksmooth}{ksmooth}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
data(geyser, package="MASS")
x <- geyser$duration
h <- dpik(x)
est <- bkde(x,bandwidth=h)
plot(est,type="l")
\end{ExampleCode}
\end{Examples}

