View source: R/sim_markov_chain.R
sim_markov_chain | R Documentation |
This is a simple function that will simulate a time-homogeneous Markov chain; that is, a Markov chain with constant transition probabilities.
sim_markov_chain(x0, p, n_cycles = 85)
x0 |
The state vector at model cycle 0 (i.e., the initial state vector). |
p |
The transition probability matrix. |
n_cycles |
The number of model cycles. Default is 85 as in the example from the tutorials. |
x0 <- c(1, 0, 0, 0) p <- matrix( c(0.848, 0.15, 0, 0.002, 0.5, 0.395, 0.105, 0.006, 0, 0, 0.98, 0.02, 0, 0, 0, 1), byrow = TRUE, nrow = 4, ncol = 4 ) sim_markov_chain(x0 = x0, p = p, n_cycles = 2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.