Last chance! 50% off unlimited learning
Sale ends in
This function is used to perform cross-validation and build the final model using the signal compression approach for the following linear multivariate scalar-on-function regression model:
We require that all the sample curves of each functional predictor are observed in a common dense grid of time points, but the grid can be different for different predictors. All the sample curves of the functional response are observed in a common dense grid.
cv.msof(X, Y, t.x.list, nbasis = 50, K.cv = 5, upper.comp = 10,
thresh = 0.001)
a list of length
an
a list of length
the number of basis functions used for estimating the vector of functions
the number of CV folds. Default is 5.
the upper bound for the maximum number of components to be calculated. Default is 10.
a number between 0 and 1 used to determine the maximum number of components we need to calculate. The maximum number is between one and the "upp.comp" above. The optimal number of components will be chosen between 1 and this maximum number, together with other tuning parameters by cross-validation. A smaller thresh value leads to a larger maximum number of components and a longer running time. A larger thresh value needs less running time, but may miss some important components and lead to a larger prediction error. Default is 0.001.
An object of the ``cv.msof'' class, which is used in the function pred.msof
for prediction.
a list containing information about fitted model.
a logic value indicating whether Y
is a
vector.
input data Y
.
a list for internal use.
We use the decomposition
Ruiyan Luo and Xin Qi (Submitted)
# NOT RUN {
#########################################################################
# Example: multiple scalar-on-function regression
#########################################################################
ptm <- proc.time()
library(FRegSigCom)
data(corn)
X=corn$X
Y=corn$Y
ntrain=60 # in paper, we use 80 observations as training data
xtrange=c(0,1) # the range of t in x(t).
t.x.list=list(seq(0,1,length.out=ncol(X)))
train.index=sample(1:nrow(X), ntrain)
X.train <- X.test <- list()
X.train[[1]]=X[train.index,]
X.test[[1]]=X[-(train.index),]
Y.train <- Y[train.index,]
Y.test <- Y[-(train.index),]
fit.cv.1=cv.msof(X.train, Y.train, t.x.list)# the cv procedure for our method
Y.pred=pred.msof(fit.cv.1, X.test) # make prediction on the test data
pred.error=mean((Y.pred-Y.test)^2)
print(c("pred.error=",pred.error))
print(proc.time()-ptm)
# }
Run the code above in your browser using DataLab