help twoway lpolyci dialog: twoway
-------------------------------------------------------------------------------
Title
[G] graph twoway lpolyci -- Local polynomial smooth plots with CIs
Syntax
twoway lpolyci 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)
level(#) set confidence level; default is level(95)
pwidth(#) pilot bandwidth for standard error calculation
var(#) estimate of the constant conditional variance
nofit do not plot the smooth
fitplot(plottype) how to plot the smooth; default is fitplot(line)
ciplot(plottype) how to plot CIs; default is ciplot(rarea)
fcline_options change look of the smoothed line
fitarea_options change look of CI
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 lpolyci plots a local polynomial smooth of yvar on xvar by
using graph twoway line, along with a confidence interval by using graph
twoway rarea.
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.
level(#) specifies the confidence level, as a percentage, for confidence
intervals. The default is level(95) or as set by set level.
pwidth(#) specifies the pilot bandwidth to be used for standard error
computations. The default is chosen to be 1.5 times the value of the
rule-of-thumb bandwidth selector.
var(#) specifies an estimate of a constant conditional variance required
for standard error computation. By default, the conditional variance
at each smoothing point is estimated by the normalized weighted
residual sum of squares obtained from locally fitting a polynomial of
order p+2, where p is the degree specified in degree().
nofit prevents the smooth from being plotted.
fitplot(plottype) specifies how the prediction is to be plotted. The
default is fitplot(line), meaning that the smooth will be plotted by
graph twoway line. See [G] graph twoway for a list of plottype
choices. You may choose any that expects one y and one x variable.
fitplot() is seldom used.
ciplot(plottype) specifies how the confidence interval is to be plotted.
The default is ciplot(rarea), meaning that the confidence bounds will
be plotted by graph twoway rarea.
A reasonable alternative is ciplot(rline), which will substitute
lines around the smooth for shading. See [G] graph twoway for a list
of plottype choices. You may choose any that expects two y variables
and one x variable.
fcline_options specify how the lpoly line is rendered and its appearance;
see [G] fcline_options.
fitarea_options specify how the confidence interval is rendered; see [G]
fitarea_options. If you specify ciplot(), you should specify
whatever is appropriate instead of using fitarea_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 lpolyci yvar xvar uses the lpoly command -- see [R] lpoly --
to obtain a local polynomial smooth of yvar on xvar and confidence
intervals and uses graph twoway line and graph twoway rarea to plot
results.
Remarks are presented under the following headings:
Typical use
Use with by()
Typical use
graph twoway lpolyci can be used to overlay the confidence bands obtained
from different local polynomial smooths. For example, for local mean and
local cubic polynomial smooths:
. sysuse auto
. twoway lpolyci weight length, nofit ||
lpolyci weight length, degree(3) nofit
ciplot(rline) pstyle(ci2) ||
scatter weight length, msymbol(o)
(click to run)
The plotted area corresponds to the confidence bands for the local mean
smooth and lines correspond to confidence intervals for the local cubic
smooth.
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 lpolyci may be used with by():
. sysuse auto, clear
. twoway lpolyci weight length ||
scatter mpg weight, mcolor(o) ||
, by(foreign)
(click to run)
Also see
Manual: [G] graph twoway lpolyci
Help: [R] lpoly; [G] graph twoway lpoly