Skip to contents

predict() gives, for each row of newdata, the population survival curve \(1 - \pi + \pi S_u(t)\) (type = "survival", the default), the probability \(\pi\) of being uncured (type = "uncured"), or the linear predictor of the latency model (type = "lp"). The survival curves level off at the cured fraction \(1 - \pi\) after the last event time.

Usage

# S3 method for class 'mixture_cure'
predict(object, newdata, type = c("survival", "uncured", "lp"), times, ...)

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

Arguments

object, x

A mixture_cure() fit.

newdata

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

type

What to predict: "survival" (the default), "uncured", or "lp".

times

For "survival", the times to read the curves at.

...

Unused.

row.names, optional

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

conf_level

The confidence level. The default is the level the model was fit with.

Value

For type = "uncured" and type = "lp", a numeric vector with one value per row. For type = "survival", a data frame with the columns subject (the row of newdata), time, and estimate. as.data.frame() gives a data frame with the columns submodel ("cure" or "latency"), term, estimate, std_error, statistic, p_value, conf_low, and conf_high.

Details

as.data.frame() gives the coefficients of both models, with bootstrap standard errors and Wald tests and limits when the model was fit with n_boot (NA otherwise).

Examples

melanoma <- data.frame(
  time = c(0.3, 5.6, 5.6, 1.5, 6.4, 0.8, 6.7, 3.3, 0.6, 0.7, 3.6, 7.4, 1.8, 1.1, 1, 4.3, 3.7, 3,
    1, 2.2, 1.1, 7.7, 5.4, 3.7, 1.4, 0.7, 8, 1.9, 2.2, 8, 1.2, 4.2, 5.6, 1.9, 0.2, 7.7, 0.5, 0.1,
    1.1, 7.1),
  status = c(1, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0, 0,
    1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0),
  treatment = rep(c(0, 1), times = 20)
)
fit <- mixture_cure(Surv(time, status) ~ treatment, cure = ~ treatment, data = melanoma,
  n_boot = NULL
)
groups <- data.frame(treatment = c(0, 1))
predict(fit, newdata = groups, type = "uncured")
#> [1] 0.7316904 0.3789641
predict(fit, newdata = groups, type = "survival", times = c(1, 3, 6, 9))
#>   subject time  estimate
#> 1       1    1 0.7326995
#> 2       1    3 0.4297285
#> 3       1    6 0.2683096
#> 4       1    9 0.2683096
#> 5       2    1 0.8301080
#> 6       2    3 0.6735063
#> 7       2    6 0.6210359
#> 8       2    9 0.6210359
as.data.frame(fit)
#>   submodel        term   estimate std_error statistic p_value conf_low
#> 1     cure (Intercept)  1.0032162        NA        NA      NA       NA
#> 2     cure   treatment -1.4971635        NA        NA      NA       NA
#> 3  latency   treatment  0.2686713        NA        NA      NA       NA
#>   conf_high
#> 1        NA
#> 2        NA
#> 3        NA