npregress(x, y, criterion="rmse", bandwidth=NULL,kernel="g", control.par=list(), cv.options=list())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."g"), Epanechnikov ("e"), uniform ("u"),
quartic ("q").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
locpolygridbw,
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.npregress which is a list including:
x contains the
initial explanatory variables, y contains the
initial dependant variables,
criterion contains the chosen criterion, kernel the
kernel and degree the chosen degreermse and mae) evaluated on the
grid gridbw. If the bandwidth
bandwidth is given by the user NULL is returnedpredict.npregress,
summary.npregress,
locpoly, ibrf <- 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])
Run the code above in your browser using DataLab