Skip to contents

Samples the health state for each individual given their row of the transition probability matrix. A multinomial sampling approach is used whereby a uniform random number is compared against the cumulative probabilities to determine the next state.

Usage

sampleV(m_trans_probs, v_states_names, assert = TRUE)

Arguments

m_trans_probs

A matrix of transition probabilities with rows corresponding to individuals and columns to states.

v_states_names

Character vector of all state names in the order used throughout the model.

assert

Logical. Boolean for whether to run full assertion of inputs. This feature is useful when running probabilistic sensitivity analysis (PSA).

Value

A character vector of the sampled next state for each row of m_trans_probs.

Examples

m_probs <- matrix(
  data = c(0.8, 0.2, 0, 0, 0.1, 0.7, 0.1, 0.1),
  nrow = 2,
  byrow = TRUE
)
colnames(m_probs) <- c("H", "S1", "S2", "D")
sampleV(
  m_trans_probs = m_probs, 
  v_states_names = colnames(m_probs)
)
#> [1] "S1" "S1"