ANN: DynamicDiscreteModels.jl and HiddenMarkovModels.jl

175 views
Skip to first unread message

ben

unread,
Feb 3, 2016, 8:11:46 AM2/3/16
to julia-stats
Hi everyone,

I just pushed to METADATA DynamicDiscreteModels.jl and HiddenMarkovModels.jl

DynamicDiscreteModels.jl is the more substantial package of the two. It provides back-end support for doing inference with any model that can be described as a "partially observed discrete Markov chain". z=(x,y) is jointly a Markov chain, y is observed but not x. The scope is parameter estimation (closed-form filtering aka forward algorithm to evaluate the likelihood, filtering-smoothing aka forward-backward to construct the EM weights,...) as well as hidden/latent state inference (Viterbi algorithm). The package is designed from the ground up to allow for deeper modelling of the dynamics: the transition matrix for (x,y) can have additional structure like simple conditional independences (a hidden Markov model), be arbitrarily parametrized by a lower-dimensional parameter (an economic model of dynamic choice), etc. The README has more information as well as a simple example.

HiddenMarkovModels.jl is as of now a thin front-end package on top of DynamicDiscreteModels.jl. The scope is discrete Hidden Markov models. Thanks to DynamicDiscreteModels.jl, HiddenMarkovModels.jl is very fast: 0.061835 seconds (102 allocations: 3.057 MB) for the Baum-Welch algorithm on 100,000 observations from 2x3 hidden Markov model. For comparison ToyHMM.jl (previously announced here) takes 7.958006041 seconds (4140814448 bytes allocated, 26.85% gc time) for the same problem, or a 100+ speed-up factor.

The two packages also implement a few proposed changes to the StatsBase.StatisticalModels interface, cf the discussion over at JuliaStats/Roadmap.

Related efforts I am aware of are:
- TimeModels.jl: GARCH models, include an implementation of the Kalman filter.
- StateSpace.jl: Kalman filters and various extensions.
- HiddenMarkovModel.jl: discrete hidden state / continuous observations Hidden Markov Models, successor of ToyHMM.jl.

I would love to discuss the potentials for harmonization / mergers / semantic unification / common backends if anyone is interested.

I hope you find these packages useful and am looking forward to comments / feedback.

Best,

Ben 

jock....@gmail.com

unread,
Feb 3, 2016, 4:45:28 PM2/3/16
to julia-stats
Hi Ben,

This is fantastic work.
Just wondering what "support for deep modelling of the transition matrices" means.
Does it mean that DynamicDiscreteModels.jl supports transition probabilities conditional on covariates? E.g., via logistic regression.
Along the same lines, can DynamicDiscreteModels.jl be extended to support emission distributions that are conditional on covariates?

Cheers,
Jock

ben

unread,
Feb 3, 2016, 5:48:06 PM2/3/16
to julia-stats
Hi Jock,

Thanks for the kind words. To be clear those two packages do only _discrete_ x's and y's. ahwillia's HiddenMarkovModel.jl does more general emissions. He and I are talking about merging our packages now.

"Deep modelling" means that you define in a front-end package a mapping from "deep" statistical parameters (call them "theta") to the transition matrix "m" for z=(x,y), and then DynamicDiscreteModels.jl takes care of the rest. So you can simulate for some value theta0, estimate theta by maximum likelihood (generic optimization or EM algorithm), do viterbi filtering at some theta0 etc. The README provides an example which I hope is illustrative.

This is the way HiddenMarkovModels.jl is implemented, with little more than defining a function coef!(model,(a,b)) which maps the transition matrix "a" and the emission matrix "b" to the corresponding transition mapping  "m" for z=(x,y) (a very simple mapping in this case obviously).

The point is that coef!(model,deep-parameters) can be arbitrarily complex, like solving an economic equilibrium model given a bunch of deep structural parameters of the economy, etc. With DynamicDiscreteModels.jl you can focus on that step and DynamicDiscreteModels.jl takes care of the rest.

Time-varying covariates are not immediately supported but individual covariates in a panel data yes.

Best,

Ben
Reply all
Reply to author
Forward
0 new messages