Computes a transition probability matrix for each individual in the cohort given the current health state, time spent in that state and a list of baseline probabilities and modifiers. Probabilities are adjusted for mortality using rate ratios and time in state. The resulting matrix has one row per individual and one column for each possible next state.
Usage
update_probsV(
v_states_names,
v_occupied_state,
l_trans_probs,
v_time_in_state,
assert = TRUE
)Arguments
- v_states_names
Character vector of all state names in the order used throughout the model.
- v_occupied_state
Character vector of current state for each individual.
- l_trans_probs
Named list of transition probabilities and rate ratios; see
update_probsVfor details.- v_time_in_state
Numeric vector indicating the time spent in the current state.
- assert
Logical. Boolean for whether to run full assertion of inputs. This feature is useful when running probabilistic sensitivity analysis (PSA).
Value
A matrix of transition probabilities with rows corresponding to
individuals and columns corresponding to the health states listed in
v_states_names. Each row sums to one.
Examples
v_states_names <- c("H", "S1", "S2", "D")
v_occupied_state <- c("H", "S1")
l_trans_probs <- list(
p_HD = 0.005,
p_HS1 = 0.15,
p_S1H = 0.5,
p_S1S2 = 0.105,
p_S1D = 1 - exp(-3 * (-log(1-0.005))),
p_S2D = 1 - exp(-10 * (-log(1-0.005))), rp_S1 = 0.2,
rp_S2 = 0.29
)
v_time_in_state <- c(1, 2)
m_probs <- update_probsV(
v_states_names,
v_occupied_state,
l_trans_probs,
v_time_in_state
)
rowSums(m_probs)
#> H S1
#> 1 1