Learn R Programming

hesim (version 0.5.0)

CohortDtstmTrans: Transitions for a cohort discrete time state transition model

Description

Simulate health state transitions in a cohort discrete time state transition model.

Arguments

Format

An R6::R6Class object.

Public fields

params

Parameters for simulating health state transitions. Supports objects of class tparams_transprobs or params_mlogit.

input_data

An object of class input_mats.

cycle_length

The length of a model cycle in terms of years. The default is 1 meaning that model cycles are 1 year long.

Active bindings

start_stateprobs

A non-negative vector with length equal to the number of health states containing the probability that the cohort is in each health state at the start of the simulation. For example, if there were three states and the cohort began the simulation in state 1, then start_stateprobs = c(1, 0, 0). Automatically normalized to sum to 1. If NULL, then a vector with the first element equal to 1 and all remaining elements equal to 0.

trans_mat

A transition matrix describing the states and transitions in a discrete-time multi-state model. Only required if the model is parameterized using multinomial logistic regression. The (i,j) element represents a transition from state i to state j. Each possible transition from row i should be based on a separate multinomial logistic regression and ordered from 0 to K - 1 where K is the number of possible transitions. Transitions that are not possible should be NA. and the reference category for each row should be 0.

Methods

Public methods

Method new()

Create a new CohortDtstmTrans object.

Usage

CohortDtstmTrans$new(
  params,
  input_data = NULL,
  trans_mat = NULL,
  start_stateprobs = NULL,
  cycle_length = 1
)

Arguments

params

The params field.

input_data

The input_data field.

trans_mat

The trans_mat field.

start_stateprobs

The start_stateprobs field.

cycle_length

The cycle_length field.

Returns

A new CohortDtstmTrans object.

Method sim_stateprobs()

Simulate probability of being in each health state during each model cycle.

Usage

CohortDtstmTrans$sim_stateprobs(n_cycles)

Arguments

n_cycles

The number of model cycles to simulate the model for.

Returns

An object of class stateprobs.

Method clone()

The objects of this class are cloneable with this method.

Usage

CohortDtstmTrans$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

See Also

create_CohortDtstmTrans(), CohortDtstm

Examples

Run this code
# NOT RUN {
library("msm")
library("data.table")
set.seed(101)

# Model setup
strategies <- data.table(
  strategy_id = c(1, 2, 3),
  strategy_name = c("SOC", "New 1", "New 2")
)
patients <- data.table(patient_id = 1:2)
hesim_dat <- hesim_data(
  strategies = strategies,
  patients = patients
)
  

# Fit multi-state model with panel data via msm
qinit <- rbind(
  c(0, 0.28163, 0.01239),
  c(0, 0, 0.10204),
  c(0, 0, 0)
)
fit <- msm(state_id ~ time, subject = patient_id, 
           data = onc3p[patient_id %in% sample(patient_id, 100)],
           covariates = list("1-2" =~ strategy_name), 
           qmatrix = qinit)

# Simulation model
transmod_data <- expand(hesim_dat)
transmod <- create_CohortDtstmTrans(fit,
                                    input_data = transmod_data,
                                    cycle_length = 1/2,
                                    fixedpars = 2,
                                    n = 2)
transmod$sim_stateprobs(n_cycles = 2)
# }

Run the code above in your browser using DataLab