sim_markov_chain: Simulate a Markov chain

View source: R/sim_markov_chain.R

sim_markov_chainR Documentation

Simulate a Markov chain

Description

This is a simple function that will simulate a time-homogeneous Markov chain; that is, a Markov chain with constant transition probabilities.

Usage

sim_markov_chain(x0, p, n_cycles = 85)

Arguments

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.

Examples

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)

hesim-dev/learn-cea documentation built on April 23, 2022, 3:05 p.m.