help lowess dialog: lowess
-------------------------------------------------------------------------------
Title
[R] lowess -- Lowess smoothing
Syntax
lowess yvar xvar [if] [in] [, options]
options description
-------------------------------------------------------------------------
Main
mean running-mean smooth; default is running-line
least squares
noweight suppress weighted regressions; default is
tricube weighting function
bwidth(#) use # for the bandwidth; default is
bwidth(0.8)
logit transform dependent variable to logits
adjust adjust smoothed mean to equal mean of
dependent variable
nograph suppress graph
generate(newvar) create newvar containing smoothed values of
yvar
Plot
marker_options change look of markers (color, size, etc.)
marker_label_options add marker labels; change look or position
Smoothed line
lineopts(cline_options) affect rendition of the smoothed line
Add plots
addplot(plot) add other plots to generated graph
Y axis, X axis, Titles, Legend, Overall, By
twoway_options any of the options documented in
[G] twoway_options
-------------------------------------------------------------------------
yvar and xvar may contain time-series operators; see tsvarlist.
Menu
Statistics > Nonparametric analysis > Lowess smoothing
Description
lowess carries out a locally weighted regression of yvar on xvar,
displays the graph, and optionally saves the smoothed variable.
Warning: lowess is computationally intensive and may therefore take a
long time to run on a slow computer. Lowess calculations on 1,000
observations, for instance, require performing 1,000 regressions.
Options
+------+
----+ Main +-------------------------------------------------------------
mean specifies running-mean smoothing; the default is running-line
least-squares smoothing.
noweight prevents the use of Cleveland's tricube weighting function; the
default is to use the weighting function.
bwidth(#) specifies the bandwidth. Centered subsets of bwidth()*N
observations are used for calculating smoothed values for each point
in the data except for end points, where smaller, uncentered subsets
are used. The greater the bwidth(), the greater the smoothing. The
default is 0.8.
logit transforms the smoothed yvar into logits. Predicted values less
than 0.0001 or greater than 0.9999 are set to 1/N and 1-1/N,
respectively, before taking logits.
adjust adjusts the mean of the smoothed yvar to equal the mean of yvar by
multiplying by an appropriate factor. This option is useful when
smoothing binary (0/1) data.
nograph suppresses displaying the graph.
generate(newvar) creates newvar containing the smoothed values of yvar.
+------+
----+ Plot +-------------------------------------------------------------
marker_options affect the rendition of markers drawn at the plotted
points, including their shape, size, color, and outline; see [G]
marker_options.
marker_label_options specify if and how the markers are to be labeled;
see [G] marker_label_options.
+---------------+
----+ Smoothed line +----------------------------------------------------
lineopts(cline_options) affects the rendition of the lowess-smoothed
line; see [G] cline_options.
+-----------+
----+ Add plots +--------------------------------------------------------
addplot(plot) provides a way to add other plots to the generated graph;
see [G] addplot_option.
+---------------------------------------------+
----+ Y axis, X axis, Titles, Legend, Overall, By +----------------------
twoway_options are any of the options documented in [G] twoway_options.
These include options for titling the graph (see [G] title_options),
options for saving the graph to disk (see [G] saving_option), and the
by() option (see [G] by_option).
Examples
---------------------------------------------------------------------------
Setup
. webuse lowess1
Perform locally weighted regression of h1 on depth and display graph
. lowess h1 depth
Same as above, but use 0.4 as the bandwidth rather than the default of
0.8
. lowess h1 depth, bwidth(.4)
Same as above, but save smoothed values of h1 in x1 and suppress the
graph
. lowess h1 depth, bwidth(.4) gen(x1) nograph
---------------------------------------------------------------------------
Setup
. sysuse auto, clear
Perform locally weighted regression of foreign on mpg, labeling y axis
with Domestic for 0 and Foreign for 1
. lowess foreign mpg, ylabel(0 "Domestic" 1 "Foreign")
Same as above, but adjust mean of smoothed foreign to equal mean of
foreign
. lowess foreign mpg, ylabel(0 "Domestic" 1 "Foreign") adjust
Perform locally weighted regression of foreign on mpg, transforming the
smoothed foreign into logits and drawing a horizontal line at 0
. lowess foreign mpg, logit yline(0)
---------------------------------------------------------------------------
Also see
Manual: [R] lowess
Help: [D] ipolate, [R] smooth, [R] lpoly