[R] Markov chain simulation
Berend Hasselman
bhh at xs4all.nl
Tue Jan 28 19:46:15 CET 2014
On 28-01-2014, at 19:23, Kaptue Tchuente, Armel <armel.kaptue at sdstate.edu> wrote:
> Hi Kehl,
>
> Thank you for your reply.
>
> Indeed, there are many ways to simulate a markov chain sequence.
>
> For instance, if I assume that n=20, rnd_occ1<-c(0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1) and rnd_occ2<-c(0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0) are two markov chain sequences having the transition matrix TransitionMatrix<- matrix(c(0.7, 0.3, 0.4, 0.6),byrow=TRUE, nrow=2)
> For the first sequence the state "1" has 9 occurences while for the second sequence, the state "1" has 6 occurences.
> What I'm looking for it is an algorithm or a library to simulate efficiently such a markov chain sequence with for instance 12 ooccurences of the state ‘1'
>
I used package sos to search for Markov (using library(sos); findFn(“Markov”).
Amongst others this what I found which seem to be appropriate:
markovchain
MCMCpack
DTMCPack
and a lot more.
BTW: it’s no use asking me more about Markov. I am ignorant in that subject.
Good luck,
Berend
More information about the R-help
mailing list