*! version 1.0 5march2011
help semipar (SJ12-4: st0278)

Title

semipar -- Robinson's semiparametric regression
estimator

Syntax

semipar varlist [if] [in] [weight], nonpar(varname)
[options]

* nonpar(varname) specify variable that enters the model nonlinearly

generate(varname) generate nonparametric fit of the dependent variable

noshift parametric residuals are not shifted. See the Remarks section at the end of the help file

partial(varname) generate dependent variable partialled out from parametric fit (eventually rescaled)

degree(#) specify degree of local weighted polynomial fit used in the kernel; default is degree(1) (see lpoly)

trim(#) specify level of trimming for the probability distribution function of the variable entering the model nonlinearly; default is trim(0) (no trimming)

kernel(kernel) kernel function, where kernel can be gaussian (the default), epanechnikov, epan2, biweight, cosine, parzen, rectangle, or triangle

nograph suppress graph of the nonparametric fit

ci show confidence interval around the nonparametric fit

level(#) specify level of confidence for inference; default is level(95)

title(string) specify title of graph for the nonparametric fit

ytitle(string) specify label of y axis in graph of the nonparametric fit

xtitle(string) specify label of x axis in graph of the nonparametric fit

robust use sandwich variance formula to compute standard errors of the estimated parameters

cluster(varname) compute clustered-corrected standard errors of the estimated parameters

test(#) compute Härdle and Mammen's (1993) specification
test

nsim(#) specify number of bootstrap replicates to be done; default is nsim(100)

weight_test(varname) allow user to weight the distance between nonparametric and parametric fits for the test; default is weight_test(1/n)

* nonpar(varname) is required.

aweights and fweights are allowed; see weight.

Description

semipar estimates Robinson's (1988) double residual estimator and
estimates the nonlinear relation between the variable set in nonpar()
and the dependent variable. The nonparametric estimator used is a Gaussian
kernel-weighted local polynomial fit.

In addition, the test() option allows the user to assess whether a
polynomial adjustment could be used to approximate the nonparametric fit.

Options

nonpar(varname) specifies the variable that enters the model
nonlinearly. nonpar() is required.

generate(varname) generates the nonparametric fit of the dependent
variable.

partial(varname) generates the dependent variable partialled out from
the parametric fit.

degree(#) specifies the degree of the local weighted polynomial fit used
in the kernel. The default is degree(1) (see lpoly).

trim(#) specifies the level of trimming for the probability distribution
function of the variable entering the model nonlinearly. The default is
trim(0) (no trimming).

kernel(kernel) specifies the kernel function. The default is
kernel(gaussian). kernel can be one of the following:

gaussian specifies the Gaussian kernel function, the default.

epanechnikov specifies the Epanechnikov kernel function.

epan2 specifies the alternative Epanechnikov kernel function.

biweight specifies the biweight kernel function.

cosine specifies the cosine trace kernel function.

parzen specifies the Parzen kernel function.

rectangle specifies the rectangle kernel function.

triangle specifies the triangle kernel function.

nograph suppresses the graph of the nonparametric fit.

ci shows the confidence interval around the nonparametric fit. See end note.

level(#) specifies the level of confidence for inference. The default
is level(95).

title(string) specifies the title of the graph for the nonparametric
fit.

ytitle(string) specifies the title of the y axis in the graph of the
nonparametric fit.

xtitle(string) specifies the title of the x axis in the graph of the
nonparametric fit.

robust uses the sandwich variance formula to compute standard errors of
the estimated parameters.

cluster(varname) computes cluster-corrected standard errors of the
estimated parameters.

test(#) computes Härdle and Mammen's (1993) specification test to
assess whether the nonparametric fit can be approximated by a parametric
adjustment of order #. With the cluster() option specified,
bootstrap sample of clusters are drawn. The p-value is returned in e(p_HM).

nsim(#) specifies the number of bootstrap replicates to be done to
perform inference on the test. The default is nsim(100).

weight_test(varname) allows the user to weight the distance between the
nonparametric and parametric fits for the test. The default is
weight_test(1/n).

Examples

. clear // warning, this command removes data from memory

. use http://fmwww.bc.edu/ec-p/data/wooldridge/hprice3

. semipar lprice ldist larea lland rooms bath age, nonpar(linst) xtitle(linst) ci

Same as above but testing for the appropriateness of a polynomial
adjustment of order 2 for linst

. semipar lprice ldist larea lland rooms bath age, nonpar(linst) xtitle(linst) ci test(2)

Remarks

Note that once the parametric part has been estimated, the “parametric” residuals are recovered.
They are then shifted by adding the average value of the predicted value of the parametric fit.
This transformation does not affect the shape of the function but allows to have an idea of
how the average value of the dependent variable (rather than the parametric residuals) changes
after a change in the variable entering the model non-parametrically. We believe this should lead
results conceptually comparable to plreg by Michael Lokshin and margins and marginsplot
after npregress series (see the example below).

We would like to thank Anna Houstecka and Bernd Fitzenberger that signaled that when the “partial” option
is used, these rescaled residuals are returned rather than the raw ones. To get the raw ones,
one could either generate the prediction of the parametric part. Then, removing this prediction from the
dependent variable, would lead to the raw "parametric" residuals. Alternatively, we added a “noshift”
option to simplify this procedure. When the "noshift" option is used, the shift is not implemented
anywhere, not even for the default graph. We believe this should lead results conceptually comparable
to pspline by Ben Jann and Roberto G. Gutierrez.

Example (please install plreg and pspline; npregress series is only available for Stata 16 and higher):

. clear // warning, this command removes data from memory

. set seed 1234

. set obs 1000

. drawnorm x1-x3 e

. replace x2=x2+50

. replace x1=x1+10

. gen y=40+5*x1+x2+x3+x3^2+e

Without "noshift" option

. semipar y x1 x2, nonpar(x3) gen(semiparfit) degree(4)

. plreg y x1 x2, nlf(x3) gen(plregfit)

. npregress series y x3, asis(x1 x2) // For Stata 16 and above

. margins, at(x3=(-2.5(0.1)3.5)) nose post // For Stata 16 and above

. `"marginsplot, plotopts(msymbol(none)) addplot(line semiparfit plregfit x3, sort legend(rows(1) order(2 "npregress" 3 "semipar" 4 "plreg" ))) title(Predictive margins)"' // For Stata 16 and above

With "noshift" option

. semipar y x1 x2, nonpar(x3) noshift gen(semiparfit2) degree(4)

. pspline y x3 x1 x2, noi gen(psplinefit) at(x3)

. `"line semiparfit2 psplinefit x3, sort legend(rows(1) order(1 "semipar" 2 "pspline" ))"'

References

Härdle, W., and E. Mammen. 1993. Comparing nonparametric versus
parametric regression fits. Annals of Statistics 21: 1926-1947.

Jann, B., and R. Gutierrez. 2008. pspline: Stata module providing a penalized
spline scatterplot smoother based on linear mixed model technology. Available from
http://ideas.repec.org/c/boc/bocode/s456972.html.

Lokshin, M. 2006. Difference-based semiparametric estimation of
partial linear regression models.
The Stata Journal 6(3): 377-383.

Robinson, P. M. 1988. Root-n-consistent semiparametric regression.
Econometrica 56: 931-954.

Authors

Nicolas Debarsy

CNRS, LEM UMR 9221, Université de Lilles

Building SH2, Office 104

F-59655 Villeneuve-d’Ascq, France

nicolas.debarsy@cnrs.fr

Vincenzo Verardi

University of Namur, FNRS

(Centre for Research in the Economics of Development)

Namur, Belgium

vverardi@unamur.be

Note

No correction for the degrees of freedom is implemented for the confidence intervals associated to the non-paramatric fit.

Also see

[R] npregress from Stata 16, plreg if installed, pspline if installed

Article: Stata Journal, volume 12, number 4: st0278