*! version 1.0.0 16june2015

Title

supsmooth -- Friedman's super smoother

Syntax

supsmooth yvar xvar [if] [in]
[weight]
[, options]

Main
bwcv(numlist) bandwidths to be cross-validated;
default bandwidths are 0.05, 0.2, and 0.5

algorithm(update|wfit) specify algorithm;
default is update

alpha(#) specify oversmoothing parameter; default is
alpha(0), i.e., no oversmoothing

tricube use tricube weights for local linear fits;
available only with algorithm(wfit)

generate(newvar_s [, replace]) store
smoothed points in newvar_s

nograph suppress graph

noscatter suppress scatterplot only

Scatterplot

Smoothed line
lineopts(cline_options) affect rendition of the smoothed line

Add plots
"addplot(addplot_option:plot)" add other plots to the generated graph

Y axis, X axis, Titles, Legend, Overall
twoway_options any options other than by() documented in
[G-3] twoway_options

aweights are allowed; see weight.

Description

supsmooth performs adaptive bandwidth local linear regression
based on Friedman's super smoother algorithm;
adaptive bandwidth lowess smoothing is also available. supsmooth
smoothes yvar as a function of xvar and displays a
graph of the smoothed values.

Options

Main

bwcv(numlist) specifies the cross-validated bandwidths. Any number of
bandwidths can be specified, default bandwidths are 0.05, 0.2, and 0.5.
Specifying only one bandwidth results in a fixed bandwidth local linear
regression; bandwidths need to be in the range (0,1).

algorithm specifies the algorithm; the default (update)
is the updating algorithm proposed in
Friedman (1984); the wfit
algorithm fits local linear models in each window and is therefore slower,
especially for larger samples; wfit is numerically more
stable, potentially.

alpha(#) specifies an oversmoothing parameter which
is biasing the smooth towards the largest bandwidth specified in bwcv();
the parameter needs to be in the range [0,10] where zero corresponds to no
oversmoothing, and 10 to the maximum oversmooth in which case the estimate
is the same as a fixed bandwidth smooth with the largest bandwidth
in bwcv(); defaults to alpha=0.

tricube specifies that locally varying weights be used for the local
linear regressions; specifying this option in combination with a list of
bandwidths results in an adaptive bandwidth lowess smoother; not available
with the updating algorithm.

generate(newvar_s [, replace]) stores
the smoothed values in newvar_s; optionally, existing variables may
be replaced.

nograph suppresses drawing the graph of the estimated smooth.

noscatter suppresses superimposing a scatterplot of the observed data
over the smooth.

Scatterplot

Smoothed line

lineopts(cline_options) affects the rendition of the smoothed
line; see [G-3] cline_options.

Add plots

addplot(plot) provides a way to add other plots to the generated graph;
see [G-3] addplot_option.

Y axis, X axis, Titles, Legend, Overall

twoway_options are any of the options documented in
[G-3] twoway_options, excluding by().
These include options for titling the
graph (see [G-3] title_options) and for saving the graph to disk
(see [G-3] saving_option).

Examples

Setup

. webuse motorcycle

Original super smoother

. supsmooth accel time

Super smoother with finer grained bandwidth space

. supsmooth accel time, bw(0.05(0.05)0.8)

Adaptive bandwidth lowess smoothing

. supsmooth accel time, bw(0.05(0.05)0.8) algorithm(wfit) tricube

Stored results

supsmooth stores the following in r():

Scalars

r(N) sample size

r(alpha) oversmoothing parameter

Macros

r(depvar) outcome variable

r(indepvar) predictor variable

r(wgt) type of weight

r(wexp) weight expression

r(algorithm) algorithm used

Matrices

r(bw) bandwidths

References

Friedman, Jerome H. (1984): A variable span smoother. Technical Report No. 5,
Laboratory for Computational Statistics, Department of Statistics,
Stanford University.

Author

Joerg Luedicke

StataCorp, College Station, TX

jluedicke@stata.com