Kernel regression

The Kernel regression is a non-parametrical technique in statistics to estimate the conditional expectation of random variable.

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

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

where $$m$$ is a non-parametric function.

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

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

where $$K$$ is a kernel with a bandwith $$h$$.

Statistical implementation
kernreg2 y x, bwidth(.5) kercode(3) npoint(500) gen(kernelprediction gridofpoints)
 * Stata [kernreg2]