ANN: DynamicDiscreteModels.jl and HiddenMarkovModels.jl

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
ben
Reply | Threaded
Open this post in threaded view
|

ANN: DynamicDiscreteModels.jl and HiddenMarkovModels.jl

ben
Hi everyone,

I just pushed to METADATA [hidden email] 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:
- [hidden email]: GARCH models, include an implementation of the Kalman filter.
- [hidden email]: Kalman filters and various extensions.
- [hidden email]: 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 

--
You received this message because you are subscribed to the Google Groups "julia-stats" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: ANN: DynamicDiscreteModels.jl and HiddenMarkovModels.jl

jock.lawrie
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


On Thursday, 4 February 2016 00:11:46 UTC+11, ben wrote:
Hi everyone,

I just pushed to METADATA <a href="javascript:" target="_blank" gdf-obfuscated-mailto="54TBK7MJEgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">DynamicDiscreteModels.jl and <a href="https://github.com/BenConnault/HiddenMarkovModels.jl" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\75https%3A%2F%2Fgithub.com%2FBenConnault%2FHiddenMarkovModels.jl\46sa\75D\46sntz\0751\46usg\75AFQjCNEzVM8iqOoWV78-KKlnFNzssHhr4A&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\75https%3A%2F%2Fgithub.com%2FBenConnault%2FHiddenMarkovModels.jl\46sa\75D\46sntz\0751\46usg\75AFQjCNEzVM8iqOoWV78-KKlnFNzssHhr4A&#39;;return true;">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 <a href="https://github.com/ahwillia/ToyHMM.jl" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\75https%3A%2F%2Fgithub.com%2Fahwillia%2FToyHMM.jl\46sa\75D\46sntz\0751\46usg\75AFQjCNGiGDe5GM-i3k2UZwZhCnKWDCh9Cg&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\75https%3A%2F%2Fgithub.com%2Fahwillia%2FToyHMM.jl\46sa\75D\46sntz\0751\46usg\75AFQjCNGiGDe5GM-i3k2UZwZhCnKWDCh9Cg&#39;;return true;">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 <a href="https://github.com/JuliaStats/Roadmap.jl/issues/20#issuecomment-178849347" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\75https%3A%2F%2Fgithub.com%2FJuliaStats%2FRoadmap.jl%2Fissues%2F20%23issuecomment-178849347\46sa\75D\46sntz\0751\46usg\75AFQjCNErgOKeGvrIoHVEnEW-8D0hm00iYQ&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\75https%3A%2F%2Fgithub.com%2FJuliaStats%2FRoadmap.jl%2Fissues%2F20%23issuecomment-178849347\46sa\75D\46sntz\0751\46usg\75AFQjCNErgOKeGvrIoHVEnEW-8D0hm00iYQ&#39;;return true;">JuliaStats/Roadmap.

Related efforts I am aware of are:
- <a href="javascript:" target="_blank" gdf-obfuscated-mailto="54TBK7MJEgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">TimeModels.jl: GARCH models, include an implementation of the Kalman filter.
- <a href="javascript:" target="_blank" gdf-obfuscated-mailto="54TBK7MJEgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">StateSpace.jl: Kalman filters and various extensions.
- <a href="javascript:" target="_blank" gdf-obfuscated-mailto="54TBK7MJEgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">HiddenMarkovModel.jl: discrete hidden state / continuous observations Hidden Markov Models, successor of <a href="https://github.com/ahwillia/ToyHMM.jl" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\75https%3A%2F%2Fgithub.com%2Fahwillia%2FToyHMM.jl\46sa\75D\46sntz\0751\46usg\75AFQjCNGiGDe5GM-i3k2UZwZhCnKWDCh9Cg&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\75https%3A%2F%2Fgithub.com%2Fahwillia%2FToyHMM.jl\46sa\75D\46sntz\0751\46usg\75AFQjCNGiGDe5GM-i3k2UZwZhCnKWDCh9Cg&#39;;return true;">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 

--
You received this message because you are subscribed to the Google Groups "julia-stats" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
ben
Reply | Threaded
Open this post in threaded view
|

Re: ANN: DynamicDiscreteModels.jl and HiddenMarkovModels.jl

ben
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

On Wednesday, February 3, 2016 at 4:45:28 PM UTC-5, [hidden email] wrote:
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


On Thursday, 4 February 2016 00:11:46 UTC+11, ben wrote:
Hi everyone,

I just pushed to METADATA DynamicDiscreteModels.jl and <a href="https://github.com/BenConnault/HiddenMarkovModels.jl" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\75https%3A%2F%2Fgithub.com%2FBenConnault%2FHiddenMarkovModels.jl\46sa\75D\46sntz\0751\46usg\75AFQjCNEzVM8iqOoWV78-KKlnFNzssHhr4A&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\75https%3A%2F%2Fgithub.com%2FBenConnault%2FHiddenMarkovModels.jl\46sa\75D\46sntz\0751\46usg\75AFQjCNEzVM8iqOoWV78-KKlnFNzssHhr4A&#39;;return true;">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 <a href="https://github.com/ahwillia/ToyHMM.jl" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\75https%3A%2F%2Fgithub.com%2Fahwillia%2FToyHMM.jl\46sa\75D\46sntz\0751\46usg\75AFQjCNGiGDe5GM-i3k2UZwZhCnKWDCh9Cg&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\75https%3A%2F%2Fgithub.com%2Fahwillia%2FToyHMM.jl\46sa\75D\46sntz\0751\46usg\75AFQjCNGiGDe5GM-i3k2UZwZhCnKWDCh9Cg&#39;;return true;">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 <a href="https://github.com/JuliaStats/Roadmap.jl/issues/20#issuecomment-178849347" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\75https%3A%2F%2Fgithub.com%2FJuliaStats%2FRoadmap.jl%2Fissues%2F20%23issuecomment-178849347\46sa\75D\46sntz\0751\46usg\75AFQjCNErgOKeGvrIoHVEnEW-8D0hm00iYQ&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\75https%3A%2F%2Fgithub.com%2FJuliaStats%2FRoadmap.jl%2Fissues%2F20%23issuecomment-178849347\46sa\75D\46sntz\0751\46usg\75AFQjCNErgOKeGvrIoHVEnEW-8D0hm00iYQ&#39;;return true;">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 <a href="https://github.com/ahwillia/ToyHMM.jl" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\75https%3A%2F%2Fgithub.com%2Fahwillia%2FToyHMM.jl\46sa\75D\46sntz\0751\46usg\75AFQjCNGiGDe5GM-i3k2UZwZhCnKWDCh9Cg&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\75https%3A%2F%2Fgithub.com%2Fahwillia%2FToyHMM.jl\46sa\75D\46sntz\0751\46usg\75AFQjCNGiGDe5GM-i3k2UZwZhCnKWDCh9Cg&#39;;return true;">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 

--
You received this message because you are subscribed to the Google Groups "julia-stats" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.