In more complex Markov models state values or transition probabilities can vary with time. These models are called non-homogeneous or time-inhomogeneous Markov models. A further distinction can be made depending on whether state values or transition probabilities:
These two situations can be modelled using the
model_time (or its alias
state_time variables, respectively.
These variables takes increasing values with each cycles, starting from 1. For example the age of individuals at any moment can be defined as
Initial age + model_time. The time an individual spends in a state is equal to
Both variables can be used in
define_parameters( mr = exp(- state_time * lambda), age = 50 + model_time ) define_state( cost = 100 - state_time, effect = 10 ) <- function(x) abs(sin(x)) f define_transition( f(state_time), C, 1, .9 .)
model_time in a model does not change the execution speed of the analysis. On the other hand adding
state_time may slow down the analysis, especially if the model is run for many cycles and a transition probability depends on
To mitigate this drawback it is possible to limit the number of state expansion with
state_time_limit. Because most time-varying values reach an asymptotic value quite fast, it is unnecessary to expand the states any further. The last cycle value is repeated until the end.
The limit can be defined globally, per state, or per model and state. In the following example probabilities are kept constant after 10 cycles for state B and 20 cycles for state D in strategy I, and 15 cycles in state B in strategy II.
run_model( I = strat_1, II = strat_2, cycles = 100, state_time_limit = list( I = c(B = 10, D = 20), II = c(B = 15) ))
In this situation the complexity is proportional to the square of the number of cycles.↩︎