Learn R Programming

sharpPen (version 2.0)

relsharp_bigh_c: Ridge/Enet/LASSO Sharpening via the local polynomial regression with large bandwidth and then applying the residual sharpening method.

Description

This is a function to shrink responses towards their estimations of local polynomial regression with large bandwidth and then apply residual sharpening as a form of data sharpening to remove roughness, prior to use in local polynomial regression.

Usage

relsharp_bigh_c(x, y, alpha, bigh, hband)

Value

numeric matrix of sharpened responses, with each column corresponding to different values of alpha

Arguments

x

numeric vector of equally spaced x data. Missing values are not accepted.

y

vector of y data. Missing values are not accepted.

alpha

the elasticnet mixing parameter vector, with alpha in [0,1].

bigh

the kernel bandwidth smoothing parameter.

hband

the kernel bandwidth smoothing parameter, which will be used in the residual sharpening method.

Author

D.Wang

Details

Note that the predictor values are assumed to be equally spaced.

Examples

Run this code
x<-seq(0,10,length=100)
g <- function(x) sin(x)
y<-g(x)+rnorm(100)
ys<-relsharp_bigh_c(x, y,alpha=c(0.2,0.8), dpill(x,y)*4, dpill(x,y))
y.lp2<-locpoly(x,ys[,1],bandwidth=dpill(x,y),degree=1,gridsize=100)
y.lp8<-locpoly(x,ys[,2],bandwidth=dpill(x,y),degree=1,gridsize=100)
y.lp<-locpoly(x,y,bandwidth=dpill(x,y),degree=1,gridsize=100)
curve(g,x,xlim=c(0,10))
lines(y.lp2,col=2)
lines(y.lp8,col=3)
lines(y.lp,col=5)
norm(as.matrix(g(x) - y.lp2$y),type="2")
norm(as.matrix(g(x) - y.lp8$y),type="2")
norm(as.matrix(g(x) - y.lp$y),type="2")

Run the code above in your browser using DataLab