\HeaderA{supsmu}{Friedman's SuperSmoother}{supsmu}
\keyword{smooth}{supsmu}
\begin{Description}\relax
Smooth the (x, y) values by Friedman's \dQuote{super smoother}.
\end{Description}
\begin{Usage}
\begin{verbatim}
supsmu(x, y, wt, span = "cv", periodic = FALSE, bass = 0)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{x}] x values for smoothing
\item[\code{y}] y values for smoothing
\item[\code{wt}] case weights, by default all equal
\item[\code{span}] the fraction of the observations in the span of the running
lines smoother, or \code{"cv"} to choose this by leave-one-out
cross-validation.
\item[\code{periodic}] if \code{TRUE}, the x values are assumed to be in
\code{[0, 1]} and of period 1.
\item[\code{bass}] controls the smoothness of the fitted curve. Values of up
to 10 indicate increasing smoothness.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
\code{supsmu} is a running lines smoother which chooses between three
spans for the lines. The running lines smoothers are symmetric, with
\code{k/2} data points each side of the predicted point, and values of
\code{k} as \code{0.5 * n}, \code{0.2 * n} and \code{0.05 * n}, where
\code{n} is the number of data points.  If \code{span} is specified,
a single smoother with span \code{span * n} is used.

The best of the three smoothers is chosen by cross-validation for each
prediction. The best spans are then smoothed by a running lines
smoother and the final prediction chosen by linear interpolation. 

The FORTRAN code says: \dQuote{For small samples (\code{n < 40}) or if
there are substantial serial correlations between observations close
in x-value, then a prespecified fixed span smoother (\code{span >
      0}) should be used.  Reasonable span values are 0.2 to 0.4.}
\end{Details}
\begin{Value}
A list with components
\begin{ldescription}
\item[\code{x}] the input values in increasing order with duplicates removed.
\item[\code{y}] the corresponding y values on the fitted curve.
\end{ldescription}
\end{Value}
\begin{References}\relax
Friedman, J. H. (1984)
SMART User's Guide.
Laboratory for Computational Statistics, Stanford University Technical
Report No. 1.

Friedman, J. H. (1984)
A variable span scatterplot smoother.
Laboratory for Computational Statistics, Stanford University Technical
Report No. 5.
\end{References}
\begin{SeeAlso}\relax
\code{\LinkA{ppr}{ppr}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
with(cars, {
    plot(speed, dist)
    lines(supsmu(speed, dist))
    lines(supsmu(speed, dist, bass = 7), lty = 2)
    })
\end{ExampleCode}
\end{Examples}

