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 |
penalized |
The matrix of penalized covariates for the new subjects. |
unpenalized |
The unpenalized covariates for the new subjects. |
data |
A |
Details
The user need only supply those terms from the original call that are different relative to the original call that produced the penfit
object. In particular, if penalized and/or unpenalized was specified in matrix form, a matrix must be given with the new subjects' data. The columns of these matrices must be exactly the same as in the matrices supplied in the original call that produced the penfit
object. If either penalized or unpenalized was given as a formula
in the original call, the user of predict
must supply a new data
argument. As with matrices, the new data
argument must have a similar make-up as the data
argument in the original call that produced the penfit
object. In particular, 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], data = nki70[51:52,])