.- help for ^knnreg^ [STB-30: snp9] .- k-Nearest Neighbor (k-NN) regression ------------------------------------ ^knnreg^ yvar xvar [^if^ exp] [^in^ range], ^k^num^(^#^)^ [ ^g^en^(^mkvar^)^ ^nog^raph graph_options ] Description ----------- ^knnreg^ calculates nonparametric regression by means of the k-Nearest Neighbor estimator. By default, ^knnreg^ draws a scatterplot of the original observations overlaid with the estimated conditional mean represented as a continuous line without any symbol. Options ------- ^k^num^(^#^)^ specifies the number of neighbors to be used for estimation. This is the smoothing parameter. ^g^en^(^mkvar^)^ creates a variable containing the regression estimations. ^nog^raph suppresses the graph. graph_options are any of the options allowed with ^graph, twoway^. Remarks ------- ^k^num is not optional. If the user does not provide it, the program halts and displays an error message on screen. The "smoothness" of the resulting estimate can be regulated by changing ^k^num: numerous neighbors produce smooth results; few neighbors gives noiser results. While using the ^gen^ option, the new variable will have the same number of observations as the original variables but containing missing values corresponding to both extrems of the sorted response values (as it is based in differences of lagged values without endpoint adjustment) This procedure can be regarded as a descriptive smoother of scatterplots besides a nonparametric regression estimator with fixed span but variable bandwidth. Examples -------- . ^knnreg wait dura, knum(11)^ . ^knnreg accel time, k(15) gen(mk15) nog^ Will calculate the k-NN estimate for ^accel^ and ^time^ using a neighbor span of 15 and will create a variable with the resulting conditional mean values (stored in mk15) without any graphical display. References ---------- 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. Authors ------- Isaias H. Salgado-Ugarte, Makoto Shimizu and Toru Taniuchi University of Tokyo, Faculty of Agriculture, Department of Fisheries, Yayoi 1-1-1, Bunkyo-ku Tokyo 113, Japan. fes01@@tzetzal.dcaa.unam.mx 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@, @kernreg@