Learn R Programming

CHsharp (version 0.4)

penlocreg: Penalized Local Polynomial Regression

Description

Data sharpened local polynomial regression subject to a given penalty.

Usage

penlocreg(x, y, xgrid, degree = 0, h, lambda, L, ...)

Arguments

x
numeric vector of predictor observations
y
numeric vector of observed responses
xgrid
numeric vector of grid points where regression function is evaluated
degree
numeric vector of local polynomial regression degree
h
numeric bandwidth
lambda
numeric penalty constant
L
function related to penalty
...
additional arguments, as required by L

Value

a list containing the original observed predictor values, the sharpened responses, the smoother matrix and the penalty matrix

Examples

Run this code
xx <- faithful$waiting 
yy <- faithful$eruptions 
h <- dpill(xx,yy)/2; lam <- 20  # tuning parameter selections 
yy.pen <- penlocreg(xx, yy, seq(min(xx), max(xx), len=401), lambda=lam, degree=1, h = h, L = 
    SecondDerivativePenalty) 
plot(xx, yy, xlab="waiting", ylab="eruptions", col="grey") 
title("Old Faithful")
points(yy.pen, col=2, cex=.6) # sharpened data points
lines(locpoly(xx, yy, bandwidth=h*2, degree=1), lwd=2) # local linear estimate
lines(locpoly(yy.pen$x, yy.pen$y, bandwidth=h, degree=1), col=2, lwd=2) # sharpened estimate 

Run the code above in your browser using DataLab