| Library: | smoother |
| See also: | regxest lregxestp regestp |
| Macro: | regxestp | |
| Description: | computes the Nadaraya-Watson estimator for multivariate regression. |
Wand/Jones (1995): Kernel Smoothing
Haerdle/Mueller (1999): Multivariate and Semiparametric Kernel Regression
| Usage: | mh = regxestp(x {,h {,K} {,v} }) | |
| Input: | ||
| x | n x (p+1), the data. In the first p columns the independent variables, in the last column the dependent variable. | |
| h | scalar, p x 1 or 1 x p, bandwidth. If not given, 20% of the range of x[,1:p] is used. | |
| K | string, kernel function on [-1,1] or Gaussian kernel "gau". If not given, the Quartic kernel "qua" is used. | |
| v | m x p, values of the independent variable on which to compute the regression. If not given, a grid of length 100 (p=1), length 30 (p=2) and length 8 (p=3) is used in case of p<4. When p>=4 then v is set to x. | |
| Output: | ||
| mh | n x (p+1) or m x (p+1) matrix, the first p columns contain the grid or the sorted x[,1:p], the second column contains the regression estimate on the values of the first p columns. | |
library("smoother")
library("plot")
;
x = 2.*pi.*(uniform(200,2)-0.5) ; independent variable
m = sum(cos(x),2) ; true function
e = uniform(200)-0.5 ; error term
x = x~(m+e)
;
mh = regxestp(x,2) ; estimate function
mh = setmask(mh,"surface","blue")
plot(x,mh) ; surface plot
setgopt(plotdisplay,1,1,"title","ROTATE!")
The Nadaraya-Watson regression estimate (blue) using Quartic kernel and bandwidth h=2 and the data are pictured.
| Library: | smoother |
| See also: | regxest lregxestp regestp |