This model agnostic function runs a single markov model for the specified duration using a base R implementation. See example_two_state_markov for an example of the required input. Alternatively use sample_markov(type = "base") and the output from sample_markov.

simulate_markov_base(
  transition = NULL,
  cohort = NULL,
  state_cost = NULL,
  intervention_cost = NULL,
  qalys = NULL,
  duration = NULL,
  discounting = NULL,
  sim = NULL,
  markov_loop_fn = NULL
)

Arguments

transition

A transition matrix, see example_two_state_markov for an example of setting this up.

cohort

A vector containing the initial state.

state_cost

A list of state costs for each intervention, see example_two_state_markov for an example of setting this up.

intervention_cost

A vector of intervention costs, see example_two_state_markov for an example of setting this up.

qalys

A list of QALYs for each intervention, see example_two_state_markov for an example of setting this up.

duration

Numeric, how many long to run the model for.

discounting

Numeric vector, the discount that should be applied to the costs and QALYs for each time period. This must be the same length as duration.

sim

Matrix with the same number of rows as the duration of the model and the same number of columns as the number of states in the model. Used to store model simulations.

markov_loop_fn

A function, defaults to ] NULL. The function to use to solve the inner markov loops. Built in examples are markov_loop (using R) and ArmaMarkovLoop (using RcppArmadillo)

Value

A list containing total costs and total QALYs as matrices across states and the duration of the model

Examples

markov_sample <- sample_markov(example_two_state_markov()) simulate_markov_base( sim = matrix(NA, nrow = 10, ncol = nrow(markov_sample$transition[[1]])), transition = markov_sample$transition[[1]], cohort = markov_sample$cohort[[1]], state_cost = markov_sample$state_cost[[1]], intervention_cost = markov_sample$intervention_cost[[1]], qalys = markov_sample$qalys[[1]], duration = 10, discounting = SpeedyMarkov::calc_discounting(1.035, 10), markov_loop_fn = SpeedyMarkov::markov_loop )
#> $total_costs #> [1] 0 #> #> $total_qalys #> [1] 4.103684 #>