predict.biglasso: Model predictions based on a fitted 'biglasso' object

View source: R/predict.R

predict.biglassoR Documentation

Model predictions based on a fitted biglasso object

Description

Extract predictions (fitted reponse, coefficients, etc.) from a fitted biglasso() object.

Usage

## S3 method for class 'biglasso'
predict(
  object,
  X,
  row.idx = 1:nrow(X),
  type = c("link", "response", "class", "coefficients", "vars", "nvars"),
  lambda,
  which = 1:length(object$lambda),
  ...
)

## S3 method for class 'mbiglasso'
predict(
  object,
  X,
  row.idx = 1:nrow(X),
  type = c("link", "response", "coefficients", "vars", "nvars"),
  lambda,
  which = 1:length(object$lambda),
  k = 1,
  ...
)

## S3 method for class 'biglasso'
coef(object, lambda, which = 1:length(object$lambda), drop = TRUE, ...)

## S3 method for class 'mbiglasso'
coef(object, lambda, which = 1:length(object$lambda), intercept = TRUE, ...)

Arguments

object

A fitted "biglasso" model object.

X

Matrix of values at which predictions are to be made. It must be a bigmemory::big.matrix() object. Not used for type="coefficients".

row.idx

Similar to that in biglasso(), it's a vector of the row indices of X that used for the prediction. 1:nrow(X) by default.

type

Type of prediction:

  • "link" returns the linear predictors

  • "response" gives the fitted values

  • "class" returns the binomial outcome with the highest probability

  • "coefficients" returns the coefficients

  • "vars" returns a list containing the indices and names of the nonzero variables at each value of lambda

  • "nvars" returns the number of nonzero coefficients at each value of lambda

lambda

Values of the regularization parameter lambda at which predictions are requested. Linear interpolation is used for values of lambda not in the sequence of lambda values in the fitted models.

which

Indices of the penalty parameter lambda at which predictions are required. By default, all indices are returned. If lambda is specified, this will override which.

...

Not used.

k

Index of the response to predict in multiple responses regression ( family="mgaussian").

drop

If coefficients for a single value of lambda are to be returned, reduce dimensions to a vector? Setting drop=FALSE returns a 1-column matrix.

intercept

Whether the intercept should be included in the returned coefficients. For family="mgaussian" only.

Value

The object returned depends on type.

Author(s)

Yaohui Zeng and Patrick Breheny

See Also

biglasso(), cv.biglasso()

Examples

## Logistic regression
data(colon)
X <- colon$X
y <- colon$y
X.bm <- as.big.matrix(X, backingfile = "")
fit <- biglasso(X.bm, y, penalty = 'lasso', family = "binomial")
coef <- coef(fit, lambda=0.05, drop = TRUE)
coef[which(coef != 0)]
predict(fit, X.bm, type="link", lambda=0.05)[1:10]
predict(fit, X.bm, type="response", lambda=0.05)[1:10]
predict(fit, X.bm, type="class", lambda=0.1)[1:10]
predict(fit, type="vars", lambda=c(0.05, 0.1))
predict(fit, type="nvars", lambda=c(0.05, 0.1))

biglasso documentation built on May 29, 2024, 1:50 a.m.