[R] Entropy of a Markov chain

Wilson, Andrew a.wilson at lancaster.ac.uk
Wed Jul 14 10:31:57 CEST 2010


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



More information about the R-help mailing list