Re: [R] Generation of a Markov Chain

2013-09-17 Thread Nordlund, Dan (DSHS/RDA)
> -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > project.org] On Behalf Of Lorenzo Isella > Sent: Tuesday, September 17, 2013 2:26 PM > To: r-h...@stat.math.ethz.ch > Subject: [R] Generation of a Markov Chain > > Dear All, >

[R] Generation of a Markov Chain

2013-09-17 Thread Lorenzo Isella
Dear All, While looking for a way to generate a Markov chain given a transition matrix, I found this http://bit.ly/1a1CFl8 but the example provided does not work on my machine y<-numeric(100) x=matrix(runif(16),4,4) for(i in 2:100) { + y[i]=which(rmultinom(1, size = 1, prob = x[y[i-1], ])