Skip to contents

predict() gives the predicted log time (type = "lp", the default), or the predicted time (type = "response"), for each row of newdata. Higher values mean longer survival. as.data.frame() gives the coefficients.

Usage

# S3 method for class 'ipc_ridge'
predict(object, newdata, type = c("lp", "response"), ...)

# S3 method for class 'ipc_ridge'
as.data.frame(x, row.names = NULL, optional = FALSE, ...)

Arguments

object, x

An ipc_ridge() fit.

newdata

A data frame with the covariates of the subjects to predict for. The default is the data the model was fit to.

type

What to predict: "lp" (the default) or "response".

...

Unused.

row.names, optional

Unused. They're part of the as.data.frame() generic.

Value

predict() gives a numeric vector with one value per row. as.data.frame() gives a data frame with the columns term and estimate, starting with the intercept.

Examples

lung <- data.frame(
  time = c(306, 455, 1010, 210, 883, 1022, 310, 361, 218, 166, 170, 654, 728, 71, 567, 144,
    613, 707, 61, 88),
  status = c(2, 2, 1, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 1, 2, 2, 2, 2),
  age = c(74, 68, 56, 57, 60, 74, 68, 71, 53, 61, 57, 68, 68, 60, 57, 67, 70, 63, 56, 57),
  sex = c(1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1)
)
fit <- ipc_ridge(Surv(time, status) ~ age + sex, data = lung, alpha = 1)
as.data.frame(fit)
#>          term   estimate
#> 1 (Intercept) 2.27905588
#> 2         age 0.05330844
#> 3         sex 0.03844395
predict(fit, newdata = data.frame(age = 60, sex = 2), type = "response")
#> [1] 258.3848