Skip to contents

predict() reads the state occupancy probabilities of a multi_state() fit at given times. Before the first stop time they're the starting distribution.

Usage

# S3 method for class 'multi_state'
predict(object, times, ...)

Arguments

object

A multi_state() fit.

times

The times to read the probabilities at.

...

Unused.

Value

A data frame with one row per group, state, and time: strata, the grouping variables, state, time, and estimate.

Examples

intervals <- data.frame(
  start = c(0, 20, 0, 0, 35, 0, 0),
  stop = c(20, 60, 45, 35, 90, 70, 30),
  from = c("healthy", "ill", "healthy", "healthy", "ill", "healthy", "healthy"),
  to = c("ill", "dead", "dead", "ill", "censor", "censor", "dead")
)
intervals$to <- factor(intervals$to, levels = c("censor", "ill", "dead"))
fit <- multi_state(Surv(start, stop, to) ~ 1, data = intervals, istate = from)
predict(fit, times = c(10, 40, 80))
#>   strata   state time estimate
#> 1    all healthy   10      1.0
#> 2    all healthy   40      0.4
#> 3    all healthy   80      0.2
#> 4    all     ill   10      0.0
#> 5    all     ill   40      0.4
#> 6    all     ill   80      0.2
#> 7    all    dead   10      0.0
#> 8    all    dead   40      0.2
#> 9    all    dead   80      0.6