# Fit a first-Order Markov Chain to a Sequence of Finite Symbols

### Description

Estimates the transition matrix and stationary distribution of a first-order Markov chain from an observed sequence of symbols.

### Usage

1 | ```
estimateMarkovChain(x, circular=TRUE)
``` |

### Arguments

`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. |

### Value

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 |

### Author(s)

Andrew Hart and Servet Mart<ed>nez

### See Also

`markov.test`

, `markov.disturbance`

, `simulateMarkovChain`

### Examples

1 2 3 4 5 6 7 8 9 | ```
#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)
``` |

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker. Vote for new features on Trello.