Does anyone have any "R" code for computing the entropy of a simple first or second order Markov chain, given a transition matrix something like the following (or the symbol vector from which it is computed)?
AGRe ARIe CSRe DIRe DSCe eos HRMe SPTe TOBe AGRe 0.0000000 0.0000000 0.0000000 0.0000000 1.0000000 0.0000000 0.0000000 0.0000000 0.0000000 ARIe 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 1.0000000 0.0000000 0.0000000 0.0000000 CSRe 0.0000000 0.0000000 0.0000000 0.0000000 1.0000000 0.0000000 0.0000000 0.0000000 0.0000000 DIRe 0.0000000 0.0000000 0.0000000 0.0000000 1.0000000 0.0000000 0.0000000 0.0000000 0.0000000 DSCe 0.1666667 0.1666667 0.0000000 0.0000000 0.1666667 0.0000000 0.1666667 0.1666667 0.1666667 eos 0.0000000 0.0000000 0.0000000 0.0000000 1.0000000 0.0000000 0.0000000 0.0000000 0.0000000 HRMe 0.0000000 0.0000000 0.0000000 1.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 NMSe 0.0000000 0.0000000 0.0000000 0.0000000 1.0000000 0.0000000 0.0000000 0.0000000 0.0000000 TOBe 0.0000000 0.0000000 1.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 [The second order matrix would have column names incorporating both prior states - e.g. "SPTe.TOBe".] I looked around at the various simple entropy functions but couldn't find anything for this specific problem - they seem mostly to assume a single numerical vector as input. Many thanks in advance for any help, Andrew Wilson ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.