help locpoly3

Title

locpoly3 -- Kernel-weighted local polynomial
regression

Syntax

locpoly2 yvar xvar
[if] [in] [weight] [,
degree:(#) width:(#)
n(#) at(atvar)
generate:([newvarx] newvary [newvarsy])
[epanechnikov | biweight | cosine |
gaussian | parzen | rectangle | triangle]
nograph noscatter
plot(plot) line_options twoway_options ]

Description

locpoly3 is a slight variation on locpoly2 that produces kernel-weighted local polynomial smooths
and returns the derivates of the conditional mean estimate. locpoly3 accepts fweights and pweights.

Options

degree(#) specifies the degree of the polynomial to be used in the
smoothing. The default is degree(0), meaning local mean
smoothing.

width(#) specifies the half-width of the kernel, that is, the
width of the smoothing window around each point. If width() is
not specified, the "default" width is used; see kdensity. This
default is inappropriate for local polynomial smoothing; roll your own.

n(#) specifies the number of points at which the smooth is to be
evaluated. The default is min(_N,50).

at(atvar) specifies a variable that contains the values at which
the smooth should be evaluated. at() allows you to easily obtain
smooths for different variables or different subsamples of a variable
and then overlay the estimates for comparison.

generate([newvarx] newvary [newvarsy])
stores the results of the estimation. newvary will contain the
estimated smooth. newvarx will contain the smoothing grid. If
at() is not specified, then both newvarx and newvary
must be specified. Otherwise, only newvary is to be specified
along with optional newvarsy. Any variables specified in addition
to newvarx and newvary contain the derivates of the
conditional mean function up to the degree specified in degree().

epanechnikov, biweight, cosine, gaussian,
parzen, rectangle, and triangle specify the kernel.
(cosine specifies the cosine trace; there is no such thing as a
cosine kernel.) The default is epanechnikov, meaning the
Epanechnikov kernel is used.

nograph suppresses drawing the graph. This option is often used
in conjunction with generate().

noscatter suppresses superimposing a scatterplot of the observed
data over the smooth. This option is useful when the number of
resulting points would be large enough to clutter the graph.

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

line_options affect the rendition of the plotted lines; see
[G-3] line_options.

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 options for saving the graph to
disk (see [G-3] saving_option).

Examples

Setup: Generate 5,000 observations from a parametric normal data-generating
process modeling the returns to college

. margte_dgps

A nonparametric regression that plots an estimate of the conditional mean
function over a scatterplot of the data

. locpoly2 lwage momsEdu

Save xgrid, yhat, and the first and second derivatives

. locpoly2 lwage momsEdu, degree(2) generate(xgrid yhat dydx1 d2ydx12)

Authors

Original Authors:

Roberto G. Gutierrez

StataCorp

College Station, TX

rgutierrez@stata.com

Jean Marie Linhart

StataCorp

College Station, TX

Jeffrey S. Pitblado

StataCorp

College Station, TX

Modifying Authors locpoly2:

Thomas Walstrum

University of Illinois at Chicago

Federal Reserve Bank of Chicago

Chicago, IL

twalstrum@frbchi.org

Scott Brave

Federal Reserve Bank of Chicago

Chicago, IL

sbrave@frbchi.org

Modifying Author locpoly3:

Martin Eckhoff Andresen

University of Oslo and Statistics Norway

Oslo, Norway

martin.eckhoff.andresen@gmail.com

Also see

Manual: [R] kdensity, [R] lowess

Help: [G-2] graph