Skip to contents

predict() gives the linear predictor, the relative subdistribution hazard, or the cumulative incidence of the modeled cause for each row of newdata (or for the subjects the model was fit to). The linear predictor is \((x - \bar{x})^\top \beta\), centered at the covariate means of the fit, and the cumulative incidence is \(1 - \exp\{-H_0(t) \exp(\eta)\}\), with \(H_0\) the Breslow estimate of the baseline cumulative subdistribution hazard at the penalized coefficients. as.data.frame() gives the coefficients and subdistribution hazard ratios, with the coefficients set to 0 by the lasso kept in the table.

Usage

# S3 method for class 'penalized_fine_gray'
predict(object, newdata, type = c("lp", "risk", "cif"), times, ...)

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

Arguments

object, x

A penalized_fine_gray() 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), "risk" (\(\exp(\eta)\)), or "cif".

times

For "cif", the times to evaluate at. The default is the event times of the cause.

...

Unused.

row.names, optional

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

Value

For "lp" and "risk", a numeric vector with one value per row of newdata. For "cif", a data frame with one row per subject and time: subject (the row of newdata), time, and estimate. as.data.frame() gives a data frame with the columns term, estimate, and hazard_ratio.

Examples

mgus <- data.frame(
  time = c(30, 45, 60, 72, 80, 95, 110, 120, 130, 150, 160, 180, 200, 210, 220, 240, 45, 95),
  status = c(1, 2, 0, 2, 1, 2, 0, 1, 2, 2, 0, 1, 1, 2, 0, 2, 0, 1),
  age = c(62, 75, 58, 80, 66, 71, 59, 64, 77, 82, 60, 68, 55, 79, 63, 74, 70, 61),
  hgb = c(13, 12, 14, 11, 13, 12, 15, 12, 11, 10, 14, 13, 12, 11, 15, 12, 13, 12)
)
mgus$event <- factor(mgus$status, levels = 0:2, labels = c("censor", "pcm", "death"))
fit <- penalized_fine_gray(Surv(time, event) ~ age + hgb,
  data = mgus, cause = "pcm", penalizer = 0.02, l1_ratio = 0
)
as.data.frame(fit)
#>   term   estimate hazard_ratio
#> 1  age -0.1088776    0.8968402
#> 2  hgb -0.1702121    0.8434859
predict(fit, newdata = data.frame(age = c(60, 75), hgb = c(14, 11)), type = "risk")
#> [1] 1.8509567 0.6024052