Learn R Programming

locpol (version 0.8.0)

locCteWeights: Local Polynomial Weights

Description

Local Constant and local Linear estimator with weight.

Usage

locCteWeightsC(x, xeval, bw, kernel, weig = rep(1, length(x)))
  locLinWeightsC(x, xeval, bw, kernel, weig = rep(1, length(x)))
  locPolWeights(x, xeval, deg, bw, kernel, weig = rep(1, length(x)))
  locWeightsEval(lpweig, y)
  locWeightsEvalC(lpweig, y)

Value

locCteWeightsC and locLinWeightsC returns a list with two components

den

Estimation of \((n*h*f(x))^{p+1}\) being \(h\) the bandwidth bw.

locWeig

\((X^TWX)^{-1}X^TW\) evaluated at xeval Matrix.

Arguments

x

x covariate data values.

y

y response data values.

xeval

Vector with evaluation points.

bw

Smoothing parameter, bandwidth.

deg

Local polynomial estimation degree (\(p\)).

kernel

Kernel used to perform the estimation, see Kernels

weig

Vector of weights for observations.

lpweig

Local polynomial weights \((X^TWX)^{-1}X^TW\) evaluated at xeval matrix.

Author

Jorge Luis Ojeda Cabrera.

Details

locCteWeightsC and locLinWeightsC computes local constant and local linear weights, say any of the entries of the vector \((X^TWX)^{-1}X^TW\) for \(p=0\) and \(p=1\) resp. locWeightsEvalC and locWeightsEval computes local the estimator for a given vector of responses y

References

Fan, J. and Gijbels, I. Local polynomial modelling and its applications\/. Chapman & Hall, London (1996).

Wand, M.~P. and Jones, M.~C. Kernel smoothing\/. Chapman and Hall Ltd., London (1995).

See Also

Kernels, locpol.

Examples

Run this code
	size <- 200
	sigma <- 0.25
	deg <- 1
	kernel <- EpaK
	bw <- .25
	xeval <- 0:100/100
	regFun <- function(x) x^3
	x <- runif(size)
	y <- regFun(x) + rnorm(x, sd = sigma)
	d <- data.frame(x, y)
	lcw <- locCteWeightsC(d$x, xeval, bw, kernel)$locWeig
	lce <- locWeightsEval(lcw, y)
	lceB <- locCteSmootherC(d$x, d$y, xeval, bw, kernel)$beta0
	mean((lce-lceB)^2)
    llw <- locLinWeightsC(d$x, xeval, bw, kernel)$locWeig
	lle <- locWeightsEval(llw, y)
	lleB <- locLinSmootherC(d$x, d$y, xeval, bw, kernel)$beta0
	mean((lle-lleB)^2)

Run the code above in your browser using DataLab