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], ])==1) }
Error in rmultinom(1, size = 1, prob = x[y[i - 1], ]) :
  too few positive probabilities

Any idea about how to fix this?
Cheers

Lorenzo

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to