Kernel regression (Nadaraya-Watson estimator) ----------------------------------------------
^kernreg1^ yvar xvar [^if^ exp] [^in^ range], ^b^width^(^#^)^ ^k^ercode^(^#^)^ ^np^oint^(^#^)^ [^g^en^(^mhvar gridvar^)^ ^nog^raph graph_options]
Description ------------
^kernreg1^ calculates the Nadaraya-Watson nonparametric regression. By default, ^kernreg1^ draws the graph of the estimated conditional mean over the grid points used for calculation connected by a line without any symbol.
Attention. Read this!! -----------------------
Differences between ^kernreg^ and ^kernreg1^: 1. if the ^b^width^(^#^)^ is not specified, an optimal bandwith is assumed (as > in kdensity), 2. supresses the {if abs(`z')<=3} condition for the Gaussian kernel, 3. uses mark `use' to take account of the `if' & `in' conditions
Options --------
^b^width^(^#^)^ specifies the smoothing parameter (bandwidth or halfwidth) of the kernel density estimation for ^xvar^. This parameter defines the width of the weight function window around each grid point. If no ^b^width^(^#^)^ is specified the default is an optimal bandwidth.
^k^ercode^(^#^)^ specifies the weight function (kernel) to calculate the requir > ed univariate densities according to the following numerical codes:
1 = Uniform 2 = Triangle 3 = Epanechnikov 4 = Quartic (Biweight) 5 = Triweight 6 = Gaussian 7 = Cosinus
^np^oint^(^#^)^ specifies the number of equally spaced points (which define a grid) in the range of ^xvar^ used for the regression estimation.
^g^en^(^mhvar gridvar^)^ creates two variables containing the estimated regress > ion (conditional mean) values and the corresponding grid points, respectively.
^nog^raph suppresses the graph.
graph_options are any of the options allowed with ^graph, twoway^.
Remarks --------
^k^ercode, and ^np^point are not optional. If the user does not provide them, the program halts and displays an error message on screen.
This program uses kernel density estimators modified from Salgado-Ugarte, et al. (1993) and based on the equations provided by Haerdle (1991) and Scott (1992).
The smoothness of the resulting estimate can be regulated by changing the bandwidth: wide intervals produce smooth results; narrow intervals give noisier estimates.
Except for the Gaussian kernel, all the functions are supported on [-1,1].
While using the ^gen^ option, if the number of cases is less than ^np^oint then the program sets the number of the observations = ^np^oint to obtain the full set of estimations.
This procedure can be regarded as a descriptive smoother of scatterplots as well as a nonparametric regression estimator (Nadaraya-Watson).
In the case of optimal bandwidth, the global S_1 keeps the value of the bandwid > th.
Examples ---------
. ^kernreg1 wait dura, bwidth(0.65) kercode(4) npoint(100)^
. ^kernreg1 accel time, b(2.4) k(4) np(100) gen(m2p4 g2p4) nog^
. ^kernreg1 postax pretax, k(6) np(100) gen(cm gp) nog^
References -----------
Chambers, J.M., W.S. Cleveland, B. Kleiner and P.A. Tukey. 1983. Graphical methods for data analysis. Wadsworth & Brooks/Cole.
Fox, J. 1990. Describing univariate distributions. In (Fox, J. & J. S. Long, eds.) Modern Methods of Data Analysis. Sage.
Haerdle, W. 1991. Smoothing techniques with implementation in S. Springer-Verlag.
Salgado-Ugarte, I.H., M. Shimizu, and T. Taniuchi. 1993. snp6: Exploring the shape of univariate data using kernel density estimators. Stata Technical Bulletin 16: 8-19.
Salgado-Ugarte, I. H., M. Shimizu, and T. Taniuchi 1995. snp6.1: ASH, WARPing, and kernel density estimation for univariate data. Stata Technical Bulletin 26: 23-31.
Salgado-Ugarte, I. H., M. Shimizu, and T. Taniuchi 1995. snp6.2: Practical rules for bandwidth selection in univariate density estimation. Stata Technical Bulletin 27: 5-19.
Scott, D. W. 1992. Multivariate density estimation: Theory, practice, and visualization. John Wiley & Sons.
Silverman, B. W. 1986. Density estimation for statistics and data analysis. Chapman and Hall.
Author ---------
Xavi Ramos Universitata Autonoma de Barcelona Departament d'economia Aplicada 08193 Bellaterra Spain xramos@volcano.uab.es
Also see ---------
STB: STB-30 snp9, STB-27 snp6.2, STB-26 snp6.1, STB-16 snp6 On-line: ^help^ for @kerneld@, @warpden@, @warpdens@, @warpreg@,@gwarpreg@