| predict.fsim {fsemipar} | R Documentation |
Prediction for FSIM
Description
predict method for the functional single-index model (FSIM) fitted using fsim.kernel.fit, fsim.kernel.fit.optim, fsim.kNN.fit and fsim.kNN.fit.optim.
Usage
## S3 method for class 'fsim.kernel'
predict(object, newdata = NULL, y.test = NULL, ...)
## S3 method for class 'fsim.kNN'
predict(object, newdata = NULL, y.test = NULL, ...)
Arguments
object |
Output of the |
newdata |
A matrix containing new observations of the functional covariate collected by row. |
y.test |
(optional) A vector containing the new observations of the response. |
... |
Further arguments passed to or from other methods. |
Details
The prediction is computed using the functions fsim.kernel.test and fsim.kernel.fit, respectively.
Value
The function returns the predicted values of the response (y) for newdata. If !is.null(y.test), it also provides the mean squared error of prediction (MSEP) computed as mean((y-y.test)^2).
If is.null(newdata) the function returns the fitted values.
Author(s)
German Aneiros Perez german.aneiros@udc.es
Silvia Novo Diaz snovo@est-econ.uc3m.es
See Also
fsim.kernel.fit and fsim.kernel.test or fsim.kNN.fit and fsim.kNN.test.
Examples
data(Tecator)
y<-Tecator$fat
X<-Tecator$absor.spectra2
train<-1:160
test<-161:215
#FSIM fit.
fit.kernel<-fsim.kernel.fit(y[train],x=X[train,],max.q.h=0.35, nknot=20,
range.grid=c(850,1050),nknot.theta=4)
fit.kNN<-fsim.kNN.fit(y=y[train],x=X[train,],max.knn=20,nknot=20,
nknot.theta=4, range.grid=c(850,1050))
test<-161:215
pred.kernel<-predict(fit.kernel,newdata=X[test,],y.test=y[test])
pred.kernel$MSEP
pred.kNN<-predict(fit.kNN,newdata=X[test,],y.test=y[test])
pred.kNN$MSEP