Fast and stable algorithm for nonparametric estimation of regression functions and their derivatives via local polynomials and local polynomial ridge regression with polynomial weight functions.
lpridge(x, y, bandwidth, deriv=0, n.out=200, x.out=NULL,
order = NULL, ridge = NULL, weight = "epa", mnew = 100,
var = FALSE)
a list including used parameters and estimator.
vector of ordered design points.
vector of observations ordered according to x.
vector of bandwidths actually used for nonparametric estimation.
order of derivative of the regression function estimated.
vector of ordered output design points.
order of the polynomial used for local polynomials.
ridging parameter used.
vector of coefficients of the kernel weight function.
force to restart the algorithm after mnew updating steps.
logical flag: whether the variance of the estimator was computed.
estimator of the derivative of order deriv of the regression function.
estimator of the variance of est (proportional to residual variance).
vector of design points, not necessarily ordered.
vector of observations of the same length as x.
bandwidth for nonparametric estimation. Either a number or a vector of the same length as x.out.
order of derivative of the regression function to be estimated; default is 0.
number of output design points at which to evaluate the estimator; defaults to 200.
vector of output design points at which to evaluate the
estimator; By default, an equidistant grid of n.out
points from min(x)
to max(x)
.
order of the polynomial used for local polynomials. The
default value is deriv + 1
.
ridging parameter. The default value performs a slight
ridging (see "Details"). ridge = 0
leads to the local polynomial
estimator without ridging.
kernel weight function. The default value is weight = "epa" for Epanechnikov weights. Other weights are "bi" for biweights (square of "epa") and "tri" for triweights (cube of "epa"). If weight is a vector, it is interpreted as vector of coefficients of the polynomial weight function. Thus, weight = "epa" is equivalent to weight = c(1,0,-1).
force to restart the algorithm after mnew updating
steps. The default value is mnew = 100. For mnew = 1
you get a
numerically "super-stable" algorithm (see refernce SBE\&G below).
logical flag: if TRUE, the variance of the estimator proportional to the residual variance is computed (see "Details" below).
described in the reference SBE\&G below. Several parameters described there are fixed either in the fortran routine or in the R-function. There, you find comments how to change them.
In S\&G, a bad finite sample behavior of local polynomials for random
design was found, and ridging of the estimator was proposed. In
lpridge()
, we use a ridging matrix corresponding to the smoothness
assumption ``The squared difference of the derivative of order
deriv of the regression function at the point of estimation and the
weighted mean of design points is bounded by the residual variance
divided by the ridge parameter.''
Thus, without any smoothness assumption, ridge = 0
would be
appropriate, and for a nearly constant derivative of order
deriv
, a ridge parameter going to infinity behaves well. For
equidistant design, ridging influences the estimator only at the
boundary. Asymptotically, the influence of any non-increasing ridge
parameter vanishes.
So far, our experience with the choice of a ridging parameter is
limited. Therefore we have chosen a default value which performs a
slight modification of the local polynomial estimator (with
denotations \(h =\) bandwidth
, \(d =\) deriv
, and
where \(n_0\) = length(x)*mean(bandwidth)/diff(range(x))
is a mean number of observations in a smoothing interval):
$$ridge = 5\sqrt{n_0} h^{2d} / ((2d+3)(2d+5))$$
For var=TRUE
, the variance of the estimator proportional to the
residual variance is computed, i.e., the exact finite sample variance of the
regression estimator is var(est) = est.var * sigma^2
.
The same as for lpepa
.
data(cars)
attach(cars)
plot(speed, dist, main = "data(cars) & lpRIDGE Regression")
myfit <- lpridge(speed,dist,bandw = 5, ridge=0) # local polynomials
lines(myfit$x.out,myfit$est,col=2)
myridge <- lpridge(speed,dist,bandw = 5) # local pol. ridge
lines(myridge$x.out,myridge$est,col=3)
mtext("bandw = 5")
legend(5,120, c("ridge = 0", "default ridging"), col = 2:3, lty = 1)
detach()
Run the code above in your browser using DataLab