fsim.kernel.test {fsemipar} | R Documentation |
Functional single-index kernel predictor
Description
This function computes predictions for a functional single-index model (FSIM) with a scalar response, which is estimated using the Nadaraya-Watson kernel estimator. It requires a functional index (\theta
), a global bandwidth (h
), and the new observations of the functional covariate (x.test
) as inputs.
Usage
fsim.kernel.test(x, y, x.test, y.test=NULL, theta, nknot.theta = 3,
order.Bspline = 3, h = 0.5, 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 |
h |
The global bandwidth. The default if 0.5. |
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:
Y_i=r(\langle\theta_0,X_i\rangle)+\varepsilon_i, \quad i=1,\dots,n,
where Y_i
denotes a scalar response,
X_i
is a functional covariate valued in a separable Hilbert space \mathcal{H}
with an inner product \langle \cdot, \cdot\rangle
. The term \varepsilon
denotes the random error, \theta_0 \in \mathcal{H}
is the unknown functional index and r(\cdot)
denotes the unknown smooth link function; n
is the training sample size.
Given \theta \in \mathcal{H}
, h>0
and a testing sample {X_j,\ j=1,\dots,n_{test}
}, the predicted responses (see the value y.estimated.test
) can be computed using the kernel procedure using
\widehat{r}_{h,\theta}(X_j)=\sum_{i=1}^nw_{n,h,\theta}(X_j,X_i)Y_i,\quad j=1,\dots,n_{test},
with Nadaraya-Watson weights
w_{n,h,\theta}(X_j,X_i)=\frac{K\left(h^{-1}d_{\theta}\left(X_i,X_j\right)\right)}{\sum_{i=1}^nK\left(h^{-1}d_{\theta}\left(X_i,X_j\right)\right)},
where
-
K
is a kernel function (see the argumentkind.of.kernel
). for
x_1,x_2 \in \mathcal{H},
d_{\theta}(x_1,x_2)=|\langle\theta,x_1-x_2\rangle|
is the projection semi-metric.
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.kernel.fit
, fsim.kernel.fit.optim
and predict.fsim.kernel
.
Alternative procedure fsim.kNN.test
.
Examples
data(Tecator)
y<-Tecator$fat
X<-Tecator$absor.spectra2
train<-1:160
test<-161:215
#FSIM fit.
ptm<-proc.time()
fit<-fsim.kernel.fit(y=y[train],x=X[train,],max.q.h=0.35, nknot=20,
range.grid=c(850,1050),nknot.theta=4)
proc.time()-ptm
fit
#FSIM prediction
test<-fsim.kernel.test(y=y[train],x=X[train,],x.test=X[test,],y.test=y[test],
theta=fit$theta.est,h=fit$h.opt,nknot.theta=4,nknot=20,
range.grid=c(850,1050))
#MSEP
test$MSE.test