Learn R Programming

bbemkr (version 1.5)

NadarayaWatsonkernel: Nadaraya-Watson kernel estimator

Description

Nadaraya (1964) and Watson (1964) proposed to estimate m as a locally weighted average, using a kernel as a weighting function.

Usage

NadarayaWatsonkernel(x, y, h, gridpoint)

Arguments

x
A set of x observations.
y
A set of y observations.
h
Optimal bandwidth chosen by the user.
gridpoint
A set of gridpoints.

Value

  • gridpointA set of gridpoints.
  • mhDensity values corresponding to the set of gridpoints.

Details

$\frac{\sum^n_{i=1}K_h(x-x_i)y_i}{\sum^n_{j=1}K_h(x-x_j)}$, where $K$ is a kernel function with a bandwidth h.

References

E. A. Nadaraya (1964) On estimating regression, Theory of probability and its applications, 9(1), 141-142. G. S. Watson (1964) Smooth regression analysis, Sankhya: The Indian Journal of Statistics (Series A), 26(4), 359-372.

Examples

Run this code
x = rnorm(100)
y = rnorm(100)
NadarayaWatsonkernel(x, y, h = 2, gridpoint = seq(-3,3,length.out = 100))

Run the code above in your browser using DataLab