estimateMarkovChain {spgs} | R Documentation |
Estimates the transition matrix and stationary distribution of a first-order Markov chain from an observed sequence of symbols.
estimateMarkovChain(x, circular=TRUE)
x |
The sequence of observed symbols as a character vector. |
purposes
circular |
Should the sequence be treated as circular for the purpose of estimation? The default is ‘TRUE’. |
A list with class ‘FiniteStateMarkovChain’ having the following components:
trans.mat |
The stochastic transition matrix estimated from x. |
stat.dist |
The stationary distribution estimated from x. |
states |
the state labels |
Andrew Hart and Servet MartÃnez
markov.test
, markov.disturbance
, simulateMarkovChain
#Obtain a random 3 x 3 stochastic matrix with rows and columns labelled "A", "B", "C"
mat <- rstochmat(3, labels=c("A", "B", "C"))
mat
#Simulate a Markov chain of length 500 using mat as the transition matrix
seq <- simulateMarkovChain(500, mat)
#Estimate mat and the stationary distribution for the Markov chain which generated seq
estimateMarkovChain(seq)