I am looking for something like the ‘msm’ package, but for discrete Markov chains. For example, if I had a transition matrix defined as such
Pi <- matrix(c(1/3,1/3,1/3,
0,2/3,1/6,
2/3,0,1/2))
for states A,B,C. How can I simulate a Markov chain according to that transition matrix?
A while back I wrote a set of functions for simulation and estimation of Discrete Markov Chain probability matrices: http://www.feferraz.net/files/lista/DTMC.R.
Relevant code for what you’re asking: