stationary distribution for HMM

86 views
Skip to first unread message

Tamas Papp

unread,
Jul 16, 2015, 4:33:57 AM7/16/15
to stan-...@googlegroups.com
Hi,

I am trying to fit a hidden markov model in which it would make
sense to suppose that the initial latent values were drawn from a
the stationary distribution of the latent transition matrix P.

I am wondering how to calculate that in Stan -- I know various
ways of doing this, but I want it to play nice with autodiff and I
have never thought about it in this context, so I don't know the
pitfalls.

I know that P is irreducible.

Suggestions, references to examples, etc are appreciated.

Best,

Tamas

Bob Carpenter

unread,
Jul 16, 2015, 3:37:49 PM7/16/15
to stan-...@googlegroups.com
I'm afraid Stan can only compute eigenvectors of symmetric
matrices (otherwise we have issues with possibly complex results).

Is there another way to do this calculation? You could
probably do it approximately by multiplying the matrix a few times.

- Bob
> --
> You received this message because you are subscribed to the Google Groups "Stan users mailing list" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to stan-users+...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

Tamas Papp

unread,
Jul 17, 2015, 10:03:03 AM7/17/15
to stan-...@googlegroups.com
Eigenvectors are overkill. For a given matrix P,

p P = p
p 1 = 1

is a linear problem (the 1 on the LHS is a vector, on the RHS a
scalar). The system is linearly dependent so you just drop one
equation from the top ones.

Thinking about this, I see no reason why this should not work
(continuous and differentiable a.a. for P). But since I have a
small sparse system, I ended up calculating the steady state in
Maxima, and copy-pasting that in to Stan, and it works fine.

(Since #680 is still unresolved, I ended up doing the same for a
matrix exponential.)

Best,

Tamas

Bob Carpenter

unread,
Jul 17, 2015, 12:57:47 PM7/17/15
to stan-...@googlegroups.com
That should work. I'm not sure how to express the solver in
terms of operations we expose --- I'm not even sure it's possible.
Ben or Michael should be able to figure this out, though.

You'd need to do it in Stan if the matrix was a parameter being
estimated.

- Bob
Reply all
Reply to author
Forward
0 new messages