Learn R Programming

hesim (version 0.2.3)

PsmCurves: Partitioned survival curves

Description

Summarize n-1 survival curves for an N state partitioned survival model.

Usage

PsmCurves

Arguments

Format

R6Class object.

Fields

input_mats

Input matrices used to predict state values by strategy and patient. Must be an object of class input_mats where each row of a matrix in "X" is a unique strategy and patient. All matrices in "X" must be sorted by strategy and patient.

params

An object of class params_surv_list.

Methods

new(input_mats, params)

Constructor for the class.

hazard(t)

Predict the hazard function as a function of time.

  • t: A numeric vector of times.

cumhazard(t)

Predict the cumulative hazard function as a function of time.

  • t: A numeric vector of times.

survival(t)

Predict the survival function as a function of time.

  • t: A numeric vector of times.

rmst(t, dr = 0)

Predict (discounted) restricted mean survival time.

  • t: A numeric vector of times.

  • dr: Discount rate.

quantile(p)

Predict quantiles of the survival distributions.

  • p: A numeric vector of probabilities for calculating quantiles.

check()

Input validation for class. Checks that fields are the correct type.

Examples

Run this code
# NOT RUN {
library("flexsurv")

# Simulation data
dt_strategies <- data.frame(strategy_id = c(1, 2, 3))
dt_patients <- data.frame(patient_id = seq(1, 3),
                          age = c(45, 50, 60),
                          female = c(0, 0, 1))
hesim_dat <- hesim_data(strategies = dt_strategies,
                        patients = dt_patients)

# Fit survival models
surv_est_data <- psm4_exdata$survival
fit1 <- flexsurv::flexsurvreg(Surv(endpoint1_time, endpoint1_status) ~ age,
                              data = surv_est_data, dist = "exp")
fit2 <- flexsurv::flexsurvreg(Surv(endpoint2_time, endpoint2_status) ~ age,
                              data = surv_est_data, dist = "exp")
fit3 <- flexsurv::flexsurvreg(Surv(endpoint3_time, endpoint3_status) ~ age,
                              data = surv_est_data, dist = "exp")
fits <- flexsurvreg_list(fit1, fit2, fit3)

# Form PsmCurves
surv_input_data <- expand(hesim_dat, by = c("strategies", "patients"))
psm_curves <- create_PsmCurves(fits, input_data = surv_input_data, n = 3,
                                bootstrap = TRUE, est_data = surv_est_data)

# Summarize survival curves
head(psm_curves$quantile(p = c(.25, .5, .75)))
head(psm_curves$survival(t = seq(0, 3, by = .1)))
head(psm_curves$rmst(t = c(2, 5)))

# }

Run the code above in your browser using DataLab