run_model: Run Markov Model

View source: R/run_model_define.R

run_modelR Documentation

Run Markov Model

Description

Runs one or more strategy. When more than one strategy is provided, all strategies should have the same states and state value names.

Usage

run_model(
  ...,
  parameters = define_parameters(),
  init = c(1000L, rep(0L, get_state_number(get_states(list(...)[[1]])) - 1)),
  cycles = 1,
  method = c("life-table", "beginning", "end"),
  cost = NULL,
  effect = NULL,
  state_time_limit = NULL,
  central_strategy = NULL,
  inflow = rep(0L, get_state_number(get_states(list(...)[[1]])))
)

run_model_(
  uneval_strategy_list,
  parameters,
  init,
  cycles,
  method,
  cost,
  effect,
  state_time_limit,
  central_strategy,
  inflow
)

Arguments

...

One or more uneval_model object.

parameters

Optional. An object generated by define_parameters().

init

numeric vector or result of define_init(), same length as number of states. Number of individuals in each state at the beginning.

cycles

positive integer. Number of Markov Cycles to compute.

method

Counting method. See details.

cost

Names or expression to compute cost on the cost-effectiveness plane.

effect

Names or expression to compute effect on the cost-effectiveness plane.

state_time_limit

Optional expansion limit for state_time, see details.

central_strategy

character. The name of the strategy at the center of the cost-effectiveness plane, for readability.

inflow

numeric vector or result of define_inflow(), similar to init. Number of new individuals in each state per cycle.

uneval_strategy_list

List of models, only used by run_model_() to avoid using ....

Details

In order to compute comparisons strategies must be similar (same states and state value names). Thus strategies can only differ through transition matrix cell values and values attached to states (but not state value names).

The initial number of individuals in each state and the number of cycle will be the same for all strategies

state_time_limit can be specified in 3 different ways:

  1. As a single value: the limit is applied to all states in all strategies. 2. As a named vector (where names are state names): the limits are applied to the given state names, for all strategies. 3. As a named list of named vectors: the limits are applied to the given state names for the given strategies.

Counting method represents where the transition should occur, based on https://journals.sagepub.com/doi/10.1177/0272989X09340585: "beginning" overestimates costs and "end" underestimates costs.

Value

A list of evaluated models with computed values.

Examples

# running a single model

mod1 <-
  define_strategy(
    transition = define_transition(
      .5, .5,
      .1, .9
    ),
    define_state(
      cost = 543,
      ly = 1
    ),
    define_state(
      cost = 432,
      ly = 1
    )
  )


res <- run_model(
  mod1,
  init = c(100, 0),
  cycles = 2,
  cost = cost,
  effect = ly
)

# running several models
mod2 <-
  define_strategy(
    transition = define_transition(
      .5, .5,
      .1, .9
    ),
    define_state(
      cost = 789,
      ly = 1
    ),
    define_state(
      cost = 456,
      ly = 1
    )
    
  )


res2 <- run_model(
  mod1, mod2,
  init = c(100, 0),
  cycles = 10,
  cost = cost,
  effect = ly
)

heemod documentation built on May 29, 2024, 8:17 a.m.