Learn R Programming

cosso (version 2.1-0)

predict.cosso: Make predictions or extract coefficients from a COSSO model

Description

Make prediction for future observations or extract the model parameters at a particular smoothing parameter.

Usage

## S3 method for class 'cosso':
predict(object,xnew,M,type=c("fit","coefficients"),...)

Arguments

object
a cosso object.
xnew
future input values for response prediction
M
a smoothing parameter value. M should be taken between 0 and p. If not provided, a cross-validation procedure will be carried out to select an appropriate value.
type
if type="fit" (default), fitted values will be returned. If type="coefficients", model coefficients will be returned. Abbreviations are allowed.
...
additional arguments for predict function.

Value

  • Either a vector of fitted values, or a list containing estimated model coefficients. When type="coefficients", three sets of coefficients will be returned.
  • Interceptthe estimated intercept
  • coefsthe estimated coefficients for kernel representers
  • thetathe estimated scale parameters for each functional component

See Also

plot.cosso

Examples

Run this code
data(ozone)
## Use half of the observations for demonstration
set.seed(27695)
train.id <- sort(sample(1:nrow(ozone),ceiling(nrow(ozone)/2)))
cossoObj <- cosso(x=ozone[train.id,2:5],y=ozone[train.id,1],nbasis=50)
## Compute model parameters
predict.cosso(cossoObj,M=2,type="c")
## Make prediction on full data
predict.cosso(cossoObj,ozone[,2:5],M=2,type="c")

Run the code above in your browser using DataLab