Learn R Programming

hesim (version 0.4.1)

CohortDtstm: Cohort discrete time state transition model

Description

Simulate outcomes from a cohort discrete time state transition model.

Arguments

Format

An R6::R6Class object.

Public fields

trans_model

The model for health state transitions. Must be an object of class CohortDtstmTrans.

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.

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 CohortDtstm object.

Usage

CohortDtstm$new(trans_model = NULL, utility_model = NULL, cost_models = NULL)

Arguments

trans_model

The trans_model field.

utility_model

The utility_model field.

cost_models

The cost_models field.

Returns

A new CohortDtstm object.

Method sim_stateprobs()

Simulate health state probabilities using CohortDtstmTrans$sim_stateprobs().

Usage

CohortDtstm$sim_stateprobs(n_cycles)

Arguments

n_cycles

The number of model cycles to simulate the model for.

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

CohortDtstm$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

CohortDtstm$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

CohortDtstm$summarize(by_grp = FALSE)

Arguments

by_grp

If TRUE, then costs and QALYs are computed by subgroup. If FALSE, then costs and QALYs are aggregated across all patients (and subgroups).

Method clone()

The objects of this class are cloneable with this method.

Usage

CohortDtstm$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

See Also

create_CohortDtstm(), CohortDtstmTrans, create_CohortDtstmTrans()

Examples

Run this code
# NOT RUN {
library("data.table")
library("nnet")
transitions_data <- data.table(multinom3_exdata$transitions)

# Treatment strategies, target population, and model structure
n_patients <- 4
patients <- transitions_data[year == 1, .(patient_id, age, female)][
 sort(sample.int(nrow(transitions_data[year == 1]), n_patients))][
   , grp_id := 1:n_patients]
hesim_dat <- hesim_data(
  patients = patients,
  strategies = data.table(strategy_id = 1:2,
                          strategy_name = c("Reference", "Intervention")),
  states = data.table(state_id = c(1, 2),
                      state_name = c("Healthy", "Sick")) # Non-death health states
)
tmat <- rbind(c(0, 1, 2),
              c(NA, 0, 1),
              c(NA, NA, NA))

# Parameter estimation
## Multinomial logistic regression
data_healthy <- transitions_data[state_from == "Healthy"]
fit_healthy <- multinom(state_to ~ strategy_name + female + age,
                        data = data_healthy, trace = FALSE)
data_sick <- droplevels(transitions_data[state_from == "Sick"])
fit_sick <- multinom(state_to ~ strategy_name + female + age,
                     data = data_sick, trace = FALSE)
transfits <- multinom_list(healthy = fit_healthy, sick = fit_sick)

## Utility
utility_tbl <- stateval_tbl(multinom3_exdata$utility,
                            dist = "beta",
                            hesim_data = hesim_dat)

## Costs
drugcost_tbl <- stateval_tbl(multinom3_exdata$costs$drugs,
                             dist = "fixed",
                             hesim_data = hesim_dat) 
medcost_tbl <- stateval_tbl(multinom3_exdata$costs$medical,
                            dist = "gamma",
                            hesim_data = hesim_dat)  

# Economic model
n_samples <- 3

## Construct model
### Transitions
transmod_data <- expand(hesim_dat)
transmod <- create_CohortDtstmTrans(transfits,
                                    input_data = transmod_data,
                                    trans_mat = tmat,
                                    n = n_samples,
                                    point_estimate = FALSE)

### Utility
utilitymod <- create_StateVals(utility_tbl, n = n_samples)

### Costs
drugcostmod <- create_StateVals(drugcost_tbl, n = n_samples)
medcostmod <- create_StateVals(medcost_tbl, n = n_samples)
costmods <- list(Drug = drugcostmod,
                 Medical = medcostmod)

### Combine
econmod <- CohortDtstm$new(trans_model = transmod,
                           utility_model = utilitymod,
                           cost_models = costmods)

## Simulate outcomes
econmod$sim_stateprobs(n_cycles = 20)
econmod$sim_qalys(dr = .03)
econmod$sim_costs(dr = .03)
econmod$summarize()
econmod$summarize(by_grp = TRUE)

# }

Run the code above in your browser using DataLab