Skip to content

rsenne/EmissionModels.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EmissionModels.jl

Stable Dev Build Status Coverage Aqua JET Code Style: Blue

A Julia package providing emission models for HiddenMarkovModels.jl. It supplies ready-to-use distributions that describe how observations are generated conditioned on the HMM's latent states.

Quick start

using Pkg
Pkg.add("HiddenMarkovModels")
Pkg.add(url="https://github.com/rsenne/EmissionModels.jl")

using EmissionModels
using HiddenMarkovModels

# Create an emission model
dist = PoissonZeroInflated(5.0, 0.3)

# Sample, evaluate densities, or fit to data
x = rand(dist)
logp = logdensityof(dist, x)
fit!(dist, observations, weights)

Distribution models

All types implement the HiddenMarkovModels emission interface (rand, logdensityof, fit!).

Count data

Type Description
PoissonZeroInflated(λ, π) Zero-inflated Poisson for excess zeros in count data.

Multivariate continuous

Type Description
MultivariateT(μ, Σ, ν) Full-covariance multivariate Student's t.
MultivariateTDiag(μ, σ², ν) Diagonal-covariance multivariate Student's t.

GLM emissions (observation depends on a control vector)

Type Description
GaussianGLM(β, σ²) Linear regression with Gaussian noise.
BernoulliGLM(β) Logistic regression for binary data.
PoissonGLM(β) Log-linear regression for count data.

GLM types support regularization via priors:

using EmissionModels: RidgePrior

β  = zeros(3)
glm = GaussianGLM(β, 1.0, RidgePrior(0.5))  # L2 regularization

Each GLM is fit via fit!(glm, y, w; control_seq=X), where control_seq (design matrix X) maps latent states to the regression covariates.

Creating custom emission models

HiddenMarkovModels.jl accepts any type that implements the following interface:

Random.rand(rng::AbstractRNG, dist::MyEmission)
DensityInterface.DensityKind(::MyEmission)      # return HasDensity()
DensityInterface.logdensityof(dist::MyEmission, obs)
StatsAPI.fit!(dist::MyEmission, obs_seq, weight_seq)

See the documentation for details.

Installation

EmissionModels.jl is not yet registered. Install from GitHub:

using Pkg
Pkg.add(url="https://github.com/rsenne/EmissionModels.jl")

Contributing

Contributions are welcome. Please follow the Julia Blue Style and add tests for new behavior. Pull requests and issues are appreciated.

License

EmissionModels.jl is licensed under the terms of the LICENSE file.

About

Implements observation models to be used with HiddenMarkovModels.jl

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages