help twoway lpoly dialog: twoway
-------------------------------------------------------------------------------
Title
[G] graph twoway lpoly -- Local polynomial smooth plots
Syntax
twoway lpoly yvar xvar [if] [in] [weight] [, options]
options description
---------------------------------------------------------------------
kernel(kernel) kernel function; default is kernel(epanechnikov)
bwidth(#) kernel bandwidth
degree(#) degree of the polynomial smooth; default is
degree(0)
n(#) obtain the smooth at # points; default is
min(N, 50)
cline_options change the look of the line
axis_choice_options associate plot with alternative axis
twoway_options titles, legends, axes, added lines and text, by,
regions, name, aspect ratio, etc.
---------------------------------------------------------------------
kernel description
---------------------------------------------------------------------
epanechnikov Epanechnikov kernel function; the default
epan2 alternative Epanechnikov kernel function
biweight biweight kernel function
cosine cosine trace kernel function
gaussian Gaussian kernel function
parzen Parzen kernel function
rectangle rectangle kernel function
triangle triangle kernel function
---------------------------------------------------------------------
fweights and aweights are allowed; see weight.
Menu
Graphics > Twoway graph (scatter, line, etc.)
Description
graph twoway lpoly plots a local polynomial smooth of yvar on xvar.
Options
kernel(kernel) specifies the kernel function for use in calculating the
weighted local polynomial estimate. The default is
kernel(epanechnikov).
bwidth(#) specifies the half-width of the kernel, the width of the
smoothing window around each point. If bwidth() is not specified, a
rule-of-thumb bandwidth estimator is calculated and used; see [R]
lpoly.
degree(#) specifies the degree of the polynomial to be used in the
smoothing. The default is degree(0), meaning local mean smoothing.
n(#) specifies the number of points at which the smooth is to be
evaluated. The default is min(N,50), where N is the number of
observations.
cline_options specify how the line is rendered and its appearance; see
[G] cline_options.
axis_choice_options associate the plot with a particular y or x axis on
the graph; see [G] axis_choice_options.
twoway_options are a set of common options supported by all twoway
graphs. These options allow you to title graphs, name graphs,
control axes and legends, add lines and text, set aspect ratios,
create graphs over by() groups, and change some advanced settings.
See [G] twoway_options.
Remarks
graph twoway lpoly yvar xvar uses the lpoly command -- see [R] lpoly --
to obtain a local polynomial smooth of yvar on xvar and uses graph twoway
line to plot the result.
Remarks are presented under the following headings:
Typical use
Use with by()
Typical use
The local polynomial smooth is often graphed on top of the data, possibly
with other smoothers or regression lines:
. sysuse auto
. twoway scatter weight length, mcolor(*.6) ||
lpoly weight length ||
lowess weight length
(click to run)
We used mcolor(*.6) to dim the points and thus make the lines stand out;
see [G] colorstyle.
Notice the y-axis title: "Mileage (mpg)/lpoly smooth: Mileage
(mpg)/lowess mpg weight". The "lpoly smooth: Mileage (mpg)" was
contributed by twoway lpoly and "lowess mpg weight" by twoway lowess.
When you overlay graphs, you nearly always need to respecify the axis
titles by using the axis_title_options ytitle() and xtitle(); see [G]
axis_title_options.
Use with by()
graph twoway lpoly may be used with by():
. sysuse auto, clear
. twoway scatter weight length, mcolor(*.6) ||
lpoly weight length, ||
, by(foreign)
(click to run)
Also see
Manual: [G] graph twoway lpoly
Help: [R] lpoly; [G] graph twoway lpolyci