fsim.kNN.test {fsemipar} | R Documentation |
Functional single-index kNN predictor
Description
This function computes predictions for a functional single-index model (FSIM) with a scalar response, which is estimated using the Nadaraya-Watson kNN estimator. It requires a functional index (), a global bandwidth (
h
), and the new observations of the functional covariate (x.test
) as inputs.
Usage
fsim.kNN.test(x, y, x.test, y.test = NULL, theta, order.Bspline = 3,
nknot.theta = 3, k = 4, kind.of.kernel = "quad", range.grid = NULL,
nknot = NULL)
Arguments
x |
Matrix containing the observations of the functional covariate in the training sample, collected by row. |
y |
Vector containing the scalar responses in the training sample. |
x.test |
Matrix containing the observations of the functional covariate in the the testing sample, collected by row. |
y.test |
(optional) Vector or matrix containing the scalar responses in the testing sample. |
theta |
Vector containing the coefficients of |
nknot.theta |
Number of regularly spaced interior knots in the B-spline expansion of |
order.Bspline |
Order of the B-spline basis functions. This is the number of coefficients in each piecewise polynomial segment. The default is 3 |
k |
The number of nearest neighbours. The default is 4. |
kind.of.kernel |
The type of kernel function used. Currently, only Epanechnikov kernel ( |
range.grid |
Vector of length 2 containing the endpoints of the grid at which the observations of the functional covariate |
nknot |
Number of regularly spaced interior knots for the B-spline expansion of the functional covariate. The default value is |
Details
The functional single-index model (FSIM) is given by the expression:
where denotes a scalar response,
is a functional covariate valued in a separable Hilbert space
with an inner product
. The term
denotes the random error,
is the unknown functional index and
denotes the unknown smooth link function;
is the training sample size.
Given ,
and a testing sample {
}, the predicted responses (see the value
y.estimated.test
) can be computed using the kNN procedure by means of
with Nadaraya-Watson weights
where
-
is a kernel function (see the argument
kind.of.kernel
). for
is the projection semi-metric.
-
, where
is the indicator function of the open ball defined by the projection semi-metric, with centre
and radius
.
If the argument y.test
is provided to the program (i. e. if(!is.null(y.test))
), the function calculates the mean squared error of prediction (see the value MSE.test
). This is computed as mean((y.test-y.estimated.test)^2)
.
Value
y.estimated.test |
Predicted responses. |
MSE.test |
Mean squared error between predicted and observed responses in the testing sample. |
Author(s)
German Aneiros Perez german.aneiros@udc.es
Silvia Novo Diaz snovo@est-econ.uc3m.es
References
Novo S., Aneiros, G., and Vieu, P., (2019) Automatic and location-adaptive estimation in functional single–index regression. Journal of Nonparametric Statistics, 31(2), 364–392, doi:10.1080/10485252.2019.1567726.
See Also
See also fsim.kNN.fit
, fsim.kNN.fit.optim
and predict.fsim.kNN
.
Alternative procedure fsim.kernel.test
.
Examples
data(Tecator)
y<-Tecator$fat
X<-Tecator$absor.spectra2
train<-1:160
test<-161:215
#FSIM fit.
ptm<-proc.time()
fit<-fsim.kNN.fit(y=y[train],x=X[train,],max.knn=20,nknot.theta=4,nknot=20,
range.grid=c(850,1050))
proc.time()-ptm
fit
#FSIM prediction
test<-fsim.kNN.test(y=y[train],x=X[train,],x.test=X[test,],y.test=y[test],
theta=fit$theta.est,k=fit$k.opt,nknot.theta=4,nknot=20,
range.grid=c(850,1050))
#MSEP
test$MSE.test