npregress {ibr}R Documentation

Local polynomials smoothing

Description

Predicted values from a local polynomials of degree less than 2.
Missing values are not allowed.

Usage

npregress(x, y, criterion="rmse", bandwidth=NULL,kernel="g",
             control.par=list(), cv.options=list())

Arguments

x

A numeric vector of explanatory variable of length n.

y

A numeric vector of variable to be explained of length n.

criterion

Character string. If the bandwidth (bandwidth) is missing or NULL the number of iterations is chosen using criterion. The criterion available is (cross-validated) rmse ("rmse") and mean (relative) absolute error.

bandwidth

The kernel bandwidth smoothing parameter (a numeric vector of either length 1).

kernel

Character string which allows to choose between gaussian kernel ("g"), Epanechnikov ("e"), uniform ("u"), quartic ("q").

control.par

A named list that control optional parameters. The two components are bandwidth for compatibility with ibr arguments and degree which controls the degree of the local polynomial regression. If argument bandwidth is not null or missing, its value is used instead control.par$bandwidth. degree must be smaller than 2. For (gaussian binned) local polynomial see locpoly

cv.options

A named list which controls the way to do cross validation with component gridbw, ntest, ntrain, Kfold, type, seed, method and npermut. gridbw is numeric vector which contains the search grid for optimal bandwidth (default to 1/n*(1+1/n)^(0:kmax), with kmax=floor(log(n*diff(range(x))/3)/log(1+1/n))). ntest is the number of observations in test set and ntrain is the number of observations in training set. Actually, only one of these is needed the other can be NULL or missing. Kfold a boolean or an integer. If Kfold is TRUE then the number of fold is deduced from ntest (or ntrain). type is a character string in random,timeseries,consecutive, interleaved and give the type of segments. seed controls the seed of random generator. npermut is the number of random draws. If cv.options is list(), then component ntest is set to 1, type is consecutive, Kfold is TRUE, and the other components are NULL, which leads to leave-one-out cross-validation.

Value

Returns an object of class npregress which is a list including:

bandwidth

The kernel bandwidth smoothing parameter.

residuals

Vector of residuals.

fitted

Vector of fitted values.

df

The effective degree of freedom of the smoother.

call

A list containing four components: x contains the initial explanatory variables, y contains the initial dependant variables, criterion contains the chosen criterion, kernel the kernel and degree the chosen degree

criteria

either a named list containing the bandwidth search grid and all the criteria (rmse and mae) evaluated on the grid gridbw. If the bandwidth bandwidth is given by the user NULL is returned

Note

See locpoly for fast binned implementation over an equally-spaced grid of local polynomial. See ibr for univariate and multivariate smoothing.

Author(s)

Pierre-Andre Cornillon, Nicolas Hengartner and Eric Matzner-Lober.

References

Wand, M. P. and Jones, M. C. (1995). Kernel Smoothing. Chapman and Hall, London.

See Also

predict.npregress, summary.npregress, locpoly, ibr

Examples

f <- function(x){sin(5*pi*x)}
n <- 100
x <- runif(n)
z <- f(x)
sigma2 <- 0.05*var(z)
erreur <- rnorm(n,0,sqrt(sigma2))
y <- z+erreur
res <- npregress(x,y,bandwidth=0.02)
summary(res)
ord <- order(x)
plot(x,y)
lines(x[ord],predict(res)[ord])

[Package ibr version 2.0-4 Index]