# fitHigherOrderMarkovChain: Functions to fit a higher order Markov chain In markovchain: Easy Handling Discrete Time Markov Chains

## Description

Given a sequence of states arising from a stationary state, it fits the underlying Markov chain distribution with higher order.

## Usage

 ```1 2 3``` ```fitHigherOrder(sequence, order = 2) seq2freqProb(sequence) seq2matHigh(sequence, order) ```

## Arguments

 `sequence` A character list. `order` Markov chain order

## Value

A list containing lambda, Q, and X.

## Note

This function is written in Rcpp.

## Author(s)

Giorgio Spedicato, Tae Seung Kang

## References

Ching, W. K., Huang, X., Ng, M. K., & Siu, T. K. (2013). Higher-order markov chains. In Markov Chains (pp. 141-176). Springer US.

Ching, W. K., Ng, M. K., & Fung, E. S. (2008). Higher-order multivariate Markov chains and their applications. Linear Algebra and its Applications, 428(2), 492-507.

package version 0.2.5

`markovchain`

## Examples

 ```1 2 3``` ```sequence<-c("a", "a", "b", "b", "a", "c", "b", "a", "b", "c", "a", "b", "c", "a" , "b", "c", "a", "b", "a", "b") fitHigherOrder(sequence) ```

### Example output

```Package:  markovchain
Version:  0.6.9.3
Date:     2017-05-08
BugReport: http://github.com/spedygiorgio/markovchain/issues

\$lambda
[1] 1.000000e+00 1.626307e-08

\$Q
\$Q[[1]]
a         b    c
a 0.125 0.4285714 0.75
b 0.750 0.1428571 0.25
c 0.125 0.4285714 0.00

\$Q[[2]]
a         b    c
a 0.1428571 0.5714286 0.25
b 0.4285714 0.2857143 0.75
c 0.4285714 0.1428571 0.00

\$X
a   b   c
0.4 0.4 0.2
```

markovchain documentation built on Aug. 24, 2018, 1:03 a.m.