\HeaderA{bkde}{Compute a Binned Kernel Density Estimate}{bkde}
\keyword{distribution}{bkde}
\keyword{smooth}{bkde}
\begin{Description}\relax
Returns x and y coordinates of the binned
kernel density estimate of the probability
density of the data.
\end{Description}
\begin{Usage}
\begin{verbatim}
bkde(x, kernel = "normal", canonical = FALSE, bandwidth,
     gridsize = 401, range.x, truncate = TRUE)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{x}] vector of observations from the distribution whose density is to
be estimated.
Missing values are not allowed.

\item[\code{bandwidth}] the kernel bandwidth smoothing parameter.
Larger values of \code{bandwidth} make smoother estimates,
smaller values of \code{bandwidth} make less smooth estimates.

\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 at which to estimate
the density.

\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, extended by the
support of the kernel.

\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
This is the binned approximation to the ordinary kernel density estimate.
Linear binning is used to obtain the bin counts.  
For each \code{x} value in the sample, the kernel is
centered on that \code{x} and the heights of the kernel at each datapoint are summed.
This sum, after a normalization, is the corresponding \code{y} value in the output.
\end{Details}
\begin{Value}
a list containing the following components:

\begin{ldescription}
\item[\code{x}] vector of sorted \code{x} values at which the estimate was computed.

\item[\code{y}] vector of density estimates
at the corresponding \code{x}.

\end{ldescription}
\end{Value}
\begin{Section}{Background}
Density estimation is a smoothing operation.
Inevitably there is a trade-off between bias in the estimate and the
estimate's variability: large bandwidths will produce smooth estimates that
may hide local features of the density; small bandwidths may introduce
spurious bumps into the estimate.
\end{Section}
\begin{References}\relax
Wand, M. P. and Jones, M. C. (1995).
\emph{Kernel Smoothing.}
Chapman and Hall, London.
\end{References}
\begin{SeeAlso}\relax
\code{\LinkA{density}{density}}, \code{\LinkA{dpik}{dpik}}, \code{\LinkA{hist}{hist}},
\code{\LinkA{ksmooth}{ksmooth}}.
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
data(geyser, package="MASS")
x <- geyser$duration
est <- bkde(x, bandwidth=0.25)
plot(est, type="l")
\end{ExampleCode}
\end{Examples}

