Learn R Programming

hesim (version 0.4.1)

Psm: N-state partitioned survival model

Description

Simulate outcomes from an N-state partitioned survival model.

Arguments

Format

An R6::R6Class object.

Public fields

survival_models

The survival models used to predict survival curves. Must be an object of class PsmCurves.

utility_model

The model for health state utility. Must be an object of class StateVals.

cost_models

The models used to predict costs by health state. Must be a list of objects of class StateVals, where each element of the list represents a different cost category.

n_states

Number of states in the partitioned survival model.

t_

A numeric vector of times at which survival curves were predicted. Determined by the argument t in $sim_curves().

survival_

Survival curves simulated using sim_curves().

stateprobs_

An object of class stateprobs simulated using $sim_stateprobs().

qalys_

An object of class qalys simulated using $sim_qalys().

costs_

An object of class costs simulated using $sim_costs().

Methods

Public methods

Method new()

Create a new Psm object.

Usage

Psm$new(survival_models, utility_model = NULL, cost_models = NULL)

Arguments

survival_models

The survival_models field.

utility_model

The utility_model field.

cost_models

The cost_models field.

Details

n_states is set equal to the number of survival models plus one.

Returns

A new Psm object.

Method sim_survival()

Simulate survival curves as a function of time using PsmCurves$sim_survival().

Usage

Psm$sim_survival(t)

Arguments

t

A numeric vector of times. The first element must be 0.

Returns

An instance of self with simulated output from PsmCurves$sim_survival() stored in stateprobs_.

Method sim_stateprobs()

Simulate health state probabilities from survival_ using a partitioned survival analysis.

Usage

Psm$sim_stateprobs()

Returns

An instance of self with simulated output of class stateprobs stored in stateprobs_.

Method sim_qalys()

Simulate quality-adjusted life-years (QALYs) as a function of stateprobs_ and utility_model. See vignette("expected-values") for details.

Usage

Psm$sim_qalys(
  dr = 0.03,
  integrate_method = c("trapz", "riemann_left", "riemann_right"),
  lys = TRUE
)

Arguments

dr

Discount rate.

integrate_method

Method used to integrate state values when computing (QALYs).

lys

If TRUE, then life-years are simulated in addition to QALYs.

Returns

An instance of self with simulated output of class qalys stored in qalys_.

Method sim_costs()

Simulate costs as a function of stateprobs_ and cost_models. See vignette("expected-values") for details.

Usage

Psm$sim_costs(
  dr = 0.03,
  integrate_method = c("trapz", "riemann_left", "riemann_right")
)

Arguments

dr

Discount rate.

integrate_method

Method used to integrate state values when computing costs.

Returns

An instance of self with simulated output of class costs stored in costs_.

Method summarize()

Summarize costs and QALYs so that cost-effectiveness analysis can be performed. See summarize_ce().

Usage

Psm$summarize()

Method clone()

The objects of this class are cloneable with this method.

Usage

Psm$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

See Also

PsmCurves, create_PsmCurves()

Examples

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

# Simulation data
strategies <- data.frame(strategy_id = c(1, 2, 3))
patients <- data.frame(patient_id = seq(1, 3),
                       age = c(45, 50, 60),
                       female = c(0, 0, 1))
states <- data.frame(state_id =  seq(1, 3),
                     state_name = paste0("state", seq(1, 3)))
hesim_dat <- hesim_data(strategies = strategies,
                        patients = patients,
                        states = states)
n_samples <- 3

# 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)

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

# Cost model(s)
cost_input_data <- expand(hesim_dat, by = c("strategies", "patients", "states"))
fit_costs_medical <- stats::lm(costs ~ female + state_name, 
                               data = psm4_exdata$costs$medical)
psm_costs_medical <- create_StateVals(fit_costs_medical, 
                                      input_data = cost_input_data, 
                                      n = n_samples)

# Utility model
utility_tbl <- stateval_tbl(tbl = data.frame(state_id = states$state_id,
                                             min = psm4_exdata$utility$lower,
                                             max = psm4_exdata$utility$upper),
                            dist = "unif",
                            hesim_data = hesim_dat)
psm_utility <- create_StateVals(utility_tbl, n = n_samples)

# Partitioned survival decision model
psm <- Psm$new(survival_models = psm_curves,
               utility_model = psm_utility,
               cost_models = list(medical = psm_costs_medical))
psm$sim_survival(t = seq(0, 5, .05))
psm$sim_stateprobs()
psm$sim_costs(dr = .03)
head(psm$costs_)
head(psm$sim_qalys(dr = .03)$qalys_)

# }

Run the code above in your browser using DataLab