Prediction from penalized models {penalized}R Documentation

Prediction based on penfit objects

Description

Predicting a response for new subjects based on a fitted penalized regression model.

Usage


## S4 method for signature 'penfit':
predict(object, penalized, unpenalized, data)

Arguments

object The fitted model (a penfit object).
penalized The penalized covariates for the new subjects. These may be specified either as a matrix or as a (one-sided) formula object. In the latter case, the formula is interpreted in terms of the data argument.
unpenalized The unpenalized covariates for the new subjects. These may be specified either as a matrix or as a (one-sided) formula object. In the latter case, the formula is interpreted in terms of the data argument.
data A data.frame used to evaluate the terms of penalized or unpenalized when these have been specified as a formula object.

Details

The terms or columns of the penalized and unpenalized arguments must be exactly the same as in the original call that produced the penfit object. Any factors in data must have the same levels.

Value

The predictions, either as a vector (logistic and Poisson models), a matrix (linear model), or a breslow object (Cox model).

Examples


data(nki70)

pen <- penalized(Surv(time, event), penalized = nki70[1:50,8:77],
    unpenalized = ~ER+Age+Diam+N+Grade, data = nki70[1:50,], lambda1 = 10)

predict(pen, nki70[51:52,8:77], ~ER+Age+Diam+N+Grade, data = nki70[51:52,])

[Package penalized version 0.9-23 Index]