powered by
Simulates a Markov chain
sim.mc(init, transition, N)
A vector of integers representing the state sequence.
The distribution of states at the first time step
The transition probability matrix of the Markov chain
The number of observations to simulate
Jared O'Connell jaredoconnell@gmail.com
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