I tried to find the second order Markov chain of the following sequence
Dat= A A B A B A A A B B A A B
I tried it on "Markov chain" package in R.
D=c("A", "A", "B", "A", "B", "A", "A", "A", "B", "B", "A", "A", "B")
fitHigherOrder(D,2)
I got this result
$Q[[2]]
A B
A 0.3333333 0.75
B 0.6666667 0.25
But from Fit and evaluate a second order transition matrix (Markov Process) in R? discussion, I am little bit confused. Suppose, if I want to calculate AA-B, from the following formula for 2nd order,
Tijk= Nijk/Nij
If I follow this formula, I got probability 1.0 for AA to B transition, as there are three times AA is followed by B and three times AA transition occurs. If I am right, then how to interpret the "Markov chain" package result? I mean what is the correct way to show/ calculate the 2nd order Markov chain?