Learn R Programming

mhsmm (version 0.4.21)

sim.mc: Markov chain simulation

Description

Simulates a Markov chain

Usage

sim.mc(init, transition, N)

Value

A vector of integers representing the state sequence.

Arguments

init

The distribution of states at the first time step

transition

The transition probability matrix of the Markov chain

N

The number of observations to simulate

Author

Jared O'Connell jaredoconnell@gmail.com

Examples

Run this code
  p <- matrix(c(.1,.3,.6,rep(1/3,3),0,.5,.5),ncol=3,byrow=TRUE)
  init <- rep(1/3,3)
  sim.mc(init,p,10)  
  
  

Run the code above in your browser using DataLab