Description Usage Arguments Value Examples
This is the function that carries out the prediction of the new observations.
1 2 |
object |
This must be a |
newdata |
A list of new observations. The format of this set of data must be the same as the training data, including the order of the variables. |
... |
Other arguments to input. |
A matrix of predictions. Since the input flars
object may have more than one estimated coefficients, the number of predictions may be more than one set. Each column of the outcome is corresponding to one set of coefficients.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | library(flars)
library(fda)
## Generate some data.
dataL=data_generation(seed = 1,uncorr = TRUE,nVar = 8,nsamples = 120,
var_type = 'm',cor_type = 3)
## Split the training data and the testing data
nTrain=80
nsamples=120
TrainIdx=seq(nTrain)
TestIdx=seq(nsamples)[-TrainIdx]
fsmTrain=lapply(dataL$x,function(fsmI) fsmI[TrainIdx,,drop=FALSE])
fsmTest=lapply(dataL$x,function(fsmI) fsmI[TestIdx,,drop=FALSE])
yTrain=dataL$y[TrainIdx]
yTest=dataL$y[TestIdx]
## Do the variable selection
out=flars(fsmTrain,yTrain,method='basis',max_selection=9,
normalize='norm',lasso=FALSE)
## Do the prediction
pred=predict(out,newdata = fsmTest)
# apply(pred,2,flars:::rmse,yTest)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.