This function makes predictions from a cross-validated sail model, using the stored "sail.fit" object, and the optimal value chosen for lambda.

# S3 method for cv.sail
predict(object, newx, newe, s = c("lambda.1se",
  "lambda.min"), ...)

# S3 method for cv.sail
coef(object, s = c("lambda.1se", "lambda.min"), ...)

Arguments

object

fitted cv.sail object

newx

matrix of new values for x at which predictions are to be made. Do not include the intercept (this function takes care of that). Must be a matrix. This argument is not used for type=c("coefficients","nonzero"). This matrix will be passed to design_sail to create the design matrix necessary for predictions. This matrix must have the same number of columns originally supplied to the sail fitting function.

newe

vector of new values for the exposure variable e. This is passed to the design_sail function.

s

Value(s) of the penalty parameter lambda at which predictions are required. Default is the value s="lambda.1se" stored on the CV object. Alternatively s="lambda.min" can be used. If s is numeric, it is taken as the value(s) of lambda to be used.

...

other arguments passed to predict.sail

Value

The object returned depends the ... argument which is passed on to the predict method for sail objects.

Details

This function makes it easier to use the results of cross-validation to make a prediction.

See also

Examples

if (FALSE) { if(interactive()){ data("sailsim") f.basis <- function(i) splines::bs(i, degree = 3) cvfit <- cv.sail(x = sailsim$x[,1:20,drop=F], y = sailsim$y, e = sailsim$e, basis = f.basis, nfolds = 10) predict(cvfit) # predict at "lambda.1se" predict(cvfit, s = "lambda.min") # predict at "lambda.min" predict(cvfit, s = 0.5) # predict at specific value of lambda predict(cvfit, type = "nonzero") # non-zero coefficients at lambda.1se } }