#jsDisabledContent { display:none; } My Account | Register | Help

Article Id: WHEBN0024144328
Reproduction Date:

 Title: Nadaraya–Watson estimator Author: World Heritage Encyclopedia Language: English Subject: Errors-in-variables models Collection: Publisher: World Heritage Encyclopedia Publication Date:

Not to be confused with Kernel principal component analysis.

The kernel regression is a non-parametric technique in statistics to estimate the conditional expectation of a random variable. The objective is to find a non-linear relation between a pair of random variables X and Y.

In any nonparametric regression, the conditional expectation of a variable $Y$ relative to a variable $X$ may be written:

$\operatorname\left\{E\right\}\left(Y | X\right) = m\left(X\right)$

where $m$ is an unknown function.

Nadaraya 1964 and Watson 1964 proposed to estimate $m$ as a locally weighted average, using a kernel as a weighting function. The Nadaraya-Watson estimator is:

$\widehat\left\{m\right\}_h\left(x\right)=\frac\left\{\sum_\left\{i=1\right\}^n K_h\left(x-X_i\right) Y_i\right\}\left\{\sum_\left\{i=1\right\}^nK_h\left(x-X_i\right)\right\}$

where $K$ is a kernel with a bandwidth $h$. The fraction is a weighting term with sum 1.

Derivation

$\operatorname\left\{E\right\}\left(Y | X\right) = \int y f\left(y|x\right) dy = \int y \frac\left\{f\left(x,y\right)\right\}\left\{f\left(x\right)\right\} dy$

Using the kernel density estimation for the joint distribution f(x,y) and f(x) with a kernel K,

$\hat\left\{f\right\}\left(x,y\right) = n^\left\{-1\right\} h^\left\{-2\right\} \sum_\left\{i=1\right\}^\left\{n\right\} K\left\left(\frac\left\{x-x_i\right\}\left\{h\right\}\right\right) K\left\left(\frac\left\{y-y_i\right\}\left\{h\right\}\right\right)$,
$\hat\left\{f\right\}\left(x\right) = n^\left\{-1\right\} h^\left\{-1\right\} \sum_\left\{i=1\right\}^\left\{n\right\} K\left\left(\frac\left\{x-x_i\right\}\left\{h\right\}\right\right)$

Priestley-Chao kernel estimator

$\widehat\left\{m\right\}_\left\{PC\right\}\left(x\right) = h^\left\{-1\right\} \sum_\left\{i=1\right\}^n \left(x_i - x_\left\{i-1\right\}\right) K\left\left(\frac\left\{x-x_i\right\}\left\{h\right\}\right\right) y_i$

Gasser-Müller kernel estimator

$\widehat\left\{m\right\}_\left\{GM\right\}\left(x\right) = h^\left\{-1\right\} \sum_\left\{i=1\right\}^n \left\left[\int_\left\{s_\left\{i-1\right\}\right\}^\left\{s_i\right\} K\left\left(\frac\left\{x-u\right\}\left\{h\right\}\right\right) du\right\right] y_i$

where $s_i = \frac\left\{x_\left\{i-1\right\} + x_i\right\}\left\{2\right\}$

Example

This example is based upon Canadian cross-section wage data consisting of a random sample taken from the 1971 Canadian Census Public Use Tapes for male individuals having common education (grade 13). There are 205 observations in total.

We consider estimating the unknown regression function using Nadaraya-Watson kernel regression via the R np package that uses automatic (data-driven) bandwidth selection; see the np vignette for an introduction to the np package.

The figure below shows the estimated regression function using a second order Gaussian kernel along with asymptotic variability bounds

360px
Estimated Regression Function.

Script for example

The following commands of the R programming language use the npreg() function to deliver optimal smoothing and to create the figure given above. These commands can be entered at the command prompt via cut and paste.

library(np) # non parametric library
data(cps71)
attach(cps71)

m <- npreg(logwage~age)

plot(m,plot.errors.method="asymptotic",
plot.errors.style="band",
ylim=c(11,15.2))

points(age,logwage,cex=.25)


Related

According to Salsburg 2002, pp. 290–1, the algorithms used in kernel regression were independently developed and used in fuzzy systems: "Coming up with almost exactly the same computer algorithm, fuzzy systems and kernel density-based regressions appear to have been developed completely independently of one another."

Statistical implementation

• kernreg2
 kernreg2 y x, bwidth(.5) kercode(3) npoint(500) gen(kernelprediction gridofpoints)