help mkern

Title

mkern - Multivariate nonparametric kernel regression

Syntax

mkern
covariates,
y(outcome)
y_fit(name)
h(#)
k(kerneltype)
model(modeltype)
[graph
save_graph(graphname)]

Description

mkern extimates a multivariate nonparametric local kernel regression, by a "radial" local mean or local linear
approach using various Kernel functions as weighting schemes (at user's choice).
Using the companion command min_cv_mkern, one can also compute the "optimal bandwidth", i.e. the bandwidth
minimizing the integrated mean square error (IMSE),
via a (computational) cross-validation (CV) approach. Users can also provide their own choice of the bandwidth,
thus producing estimation for both oversmoothing and undersmoothing cases.
Finally, as an option, mkern offers a graphical plot of the row data against predicted values
to assess the degree of smoothness of the provided estimation.

According to the mkern syntax:

covariates: is the set of covariates predicting the outcome.

y(outcome): is the outcome variable.

y_fit(name): defines the name of the variable containing the estimated fitted values.

h(#): specifies the bandwidth of the kernel weighting function.

k(kerneltype): specifies the type of kernel function to use.

model(modeltype): specifies the type of smoothing techniques to use. It may be either
"mean" (i.e., kernel local mean), or "linear" (i.e., kernel local linear).

Options

graph: provides a graphical plot of the row data against the predicted values.

save_graph(graphname) allows to save "graph" with a name a declared in graphname.

kerneltype_options

kern
epanechnikov uses a Epanechnikov kernel

epan2 uses a Epan2 kernel

gaussian uses a Normal kernel

biweight uses a Biweight (or Quartic) kernel

rectangle uses a Uniform kernel

triangle uses a Triangular kernel

tricube uses a Tricube kernel

parzen uses a Parzen kernel

cosine uses a Cosine kernel

triweight uses a Triweight kernel

modeltype_options

model
mean Smoothing technique: kernel local mean

linear Smoothing technique: kernel local linear

mkern returns the following objects:

y_fit(name) is a generated variable containing model's fitted values.

e(band) is a scalar containing the bandwidth used to estimate the model.

e(CV) is a scalar containing the value of the cross-validation objective function.

e(kern) is a local macro containing the name of the kernel function used.

Remarks

- Please remember to use the update query command before running
this program to make sure you have an up-to-date version of Stata installed.

Example

*** Example 1 ***
. global KERNEL "parzen"
. global MODEL "linear"
. global y "price"
. global xvars "mpg weight trunk"
. sysuse auto , clear
*1.Compute the "optimal bandwidth"
. min_cv_mkern $y $xvars , kern($KERNEL) modeltype($MODEL)
. global H=e(opt_bandw)
*2.Compute the "multivariate kernel fitted values"
. mkern $xvars , y($y) y_fit(y_fitted) h($H) k($KERNEL) model($MODEL) graph

*** Example 2 ***
. global KERNEL "parzen"
. global MODEL "linear"
. use http://www.stata-press.com/data/r14/motorcycle , clear
*1.Compute the "optimal bandwidth"
. min_cv_mkern accel time , kern($KERNEL) modeltype($MODEL)
. global H=e(opt_bandw)
*2.Compute the "multivariate kernel fitted values"
. mkern time , y(accel) y_fit(y_fitted) h($H) k($KERNEL) model($MODEL)
*3.Plot the results
. tw (scatter accel time ) (mspline y_fitted time)

References

Li, Q., Racine, J.S., 2006. Nonparametric Econometrics: Theory and Practice. Princeton University Press.

Pagan, A., Ullah, A., 1999. Nonparametric econometrics. Cambridge University Press: Cambridge, UK.

Hastie, T., Tibshirani, R., Freedman J., 2001. The Elements of Statistical Learning: Data Mining, Inference, and Prediction. Springer, New York.

Author

Giovanni Cerulli

IRCrES-CNR

Research Institute on Sustainable Economic Growth, National Research Council of Italy

E-mail: giovanni.cerulli@ircres.cnr.it

Also see

Online: min_cv_mkern, lpoly, locreg, npregress