Learn R Programming

sail (version 0.1.0)

predict.sail: Make predictions from a sail object

Description

Similar to other predict methods, this functions predicts fitted values, logits, coefficients and more from a fitted sail object.

Usage

# S3 method for sail
predict(object, newx, newe, s = NULL, type = c("link",
  "response", "coefficients", "nonzero", "class"), ...)

# S3 method for sail coef(object, s = NULL, ...)

Arguments

object

Fitted sail model 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 entire sequence used to create the model.

type

Type of prediction required. Type "link" gives the linear predictors for "binomial" (not implemented yet); for "gaussian" models it gives the fitted values. Type "response" gives the fitted probabilities for "binomial" (not implemented yet), for "gaussian" type "response" is equivalent to type "link". Type "coefficients" computes the coefficients at the requested values for s. Note that for "binomial" models, results are returned only for the class corresponding to the second level of the factor response (not implemented yet). Type "class" applies only to "binomial" models, and produces the class label corresponding to the maximum probability (not implemented yet). Type "nonzero" returns a list of the the nonzero coefficients for each value of s. Default: "link"

...

currently ignored

Value

The object returned depends on type.

Details

R Source code file for predict, coef, plot and print methods for the sail package Author: Sahir Bhatnagar Created: 2016 Updated: April 6, 2018

s is the new vector at which predictions are requested. If s is not in the lambda sequence used for fitting the model, the predict function will use linear interpolation to make predictions. The new values are interpolated using a fraction of predicted values from both left and right lambda indices. coef(...) is equivalent to predict(sail.object, type="coefficients",...)

See Also

predict.cv.sail

Examples

Run this code
# NOT RUN {
f.basis <- function(i) splines::bs(i, degree = 3)
fit <- sail(x = sailsim$x, y = sailsim$y, e = sailsim$e,
            basis = f.basis, dfmax = 5, nlambda = 10, maxit = 20)
predict(fit) # predicted response for whole solution path
predict(fit, s = 0.45) # predicted response for a single lambda value
predict(fit, s = c(2.15, 0.32, 0.40), type="nonzero") # nonzero coefficients
# }

Run the code above in your browser using DataLab