\Header{ksmooth}{Kernel Regression Smoother}
\keyword{smooth}{ksmooth}
\begin{Description}\relax
The Nadaraya-Watson kernel regression estimate.
\end{Description}
\begin{Usage}
\begin{verbatim}
ksmooth(x, y, kernel = c("box", "normal"), bandwidth = 0.5,
        range.x = range(x), n.points = max(100, length(x)), x.points)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{x}] input x values
\item[\code{y}] input y values
\item[\code{kernel}] the kernel to be used.
\item[\code{bandwidth}] the bandwidth. The kernels are scaled so that their
quartiles (viewed as probability densities) are at
\eqn{\pm}{+/-} \code{0.25*bandwidth}.
\item[\code{range.x}] the range of points to be covered in the output.
\item[\code{n.points}] the number of points at which to evaluate the fit.
\item[\code{x.points}] points at which to evaluate the smoothed fit. If
missing, \code{n.points} are chosen uniformly to cover \code{range.x}.
\end{ldescription}
\end{Arguments}
\begin{Value}
A list with components
\begin{ldescription}
\item[\code{x}] values at which the smoothed fit is evaluated. Guaranteed to
be in increasing order.
\item[\code{y}] fitted values corresponding to \code{x}.
\end{ldescription}
\end{Value}
\begin{Note}\relax
This function is implemented purely for compatibility with S,
although it is nowhere near as slow as the S function. Better kernel
smoothers are available in other packages.
\end{Note}
\begin{Examples}
\begin{ExampleCode}
data(cars)
with(cars, {
    plot(speed, dist)
    lines(ksmooth(speed, dist, "normal", bandwidth=2), col=2)
    lines(ksmooth(speed, dist, "normal", bandwidth=5), col=3)
})
\end{ExampleCode}
\end{Examples}

