bda (version 14.3.19)

lps.variance: compute the variance of the local polynomial regression function

Description

To compute the variance of the local polynomial regression function

Usage

lps.variance(y,x,gridsize, bw, method="Rice")

Arguments

y,x

Two numerical vectors: y is the response and x is the predictor.

bw

Smoothing parameter. Is used only when method='Wasserman' or method='heteroscedastic'.

gridsize

The size of a vector of grid points where the variance of r(x) is to be estimated. This parameter is needed only when method='heteroscedastic'.

method

We use four method to compute the variance of r(x): Method 1) Larry Wasserman--nearly unbiased. This method based on an lps object; Method 2) Rice 1984 Method 3) Gasser et al (1986) -- a variation of method 3. Method 4) For heteroscedastic errors. Need to estimate based on an lpr object. Yu and Jones (2004). Defaulty method: Rice.

Value

the variance of r(x).

Examples

Run this code
# NOT RUN {
n = 100
x=rnorm(n)
y=x^2+rnorm(n)
bw = lps.variance
par(mfrow=c(1,1))
out=lpsmooth(y,x)
#plot(out, scb=TRUE, type='l')
vrx = lps.variance(y,x)
out=lpsmooth(y,x,sd.y=sqrt(vrx), bw=0.5)
plot(y~x, pch='.')
lines(out, col=2)

x0 = seq(min(x),  max(x), length=100)
y0 = x0^2
lines(y0~x0, col=4)

 
# }

Run the code above in your browser using DataCamp Workspace