dummy-link

StateSpaceRoutines

Package implementing common state-space routines.

Readme

State-Space Routines

Build Status

This package implements some common routines for state-space models.

The provided algorithms are:

Nonlinear Estimation

The tempered particle filter is a particle filtering method which can approximate the log-likelihood value implied by a general (potentially non-linear) state space system with the following representation:

General State Space System

z_{t+1} = Φ(z_t, ϵ_t)        (transition equation)
y_t     = Ψ(z_t) + u_t       (measurement equation)

ϵ_t ∼ F_ϵ(∙; θ)
u_t ∼ N(0, HH), where HH is the variance matrix of the i.i.d measurement error
Cov(ϵ_t, u_t) = 0

Linear Estimation

Linear State Space System

z_{t+1} = CCC + TTT*z_t + RRR*ϵ_t    (transition equation)
y_t     = DD  + ZZ*z_t  + η_t        (measurement equation)

ϵ_t ∼ N(0, QQ)
η_t ∼ N(0, EE)
Cov(ϵ_t, η_t) = 0

Time-Invariant Methods

kalman_filter(data, TTT, RRR, CCC, QQ, ZZ, DD, EE, z0 = Vector(), P0 = Matrix(); allout = true, n_presample_periods = 0)
resampling_method, N_MH, n_particles, n_presample_periods, adaptive, allout, parallel)

hamilton_smoother(data, TTT, RRR, CCC, QQ, ZZ, DD, EE, z0, P0; n_presample_periods = 0)
koopman_smoother(data, TTT, RRR, CCC, QQ, ZZ, DD, z0, P0, pred, vpred; n_presample_periods = 0)
carter_kohn_smoother(data, TTT, RRR, CCC, QQ, ZZ, DD, EE, z0, P0; n_presample_periods = 0, draw_states = true)
durbin_koopman_smoother(data, TTT, RRR, CCC, QQ, ZZ, DD, EE, z0, P0; n_presample_periods = 0, draw_states = true)

For more information, see the documentation for each function (e.g. by entering ?kalman_filter in the REPL).

Regime-Switching Methods

All of the provided algorithms can handle time-varying state-space systems. To do this, define regime_indices, a Vector{Range{Int64}} of length n_regimes, where regime_indices[i] indicates the range of periods t in regime i. Let TTT_i, RRR_i, etc. denote the state-space matrices in regime i. Then the state space is given by:

z_{t+1} = CCC_i + TTT_i*z_t + RRR_i*ϵ_t    (transition equation)
y_t     = DD_i  + ZZ_i*z_t  + η_t          (measurement equation)

ϵ_t ∼ N(0, QQ_i)
η_t ∼ N(0, EE_i)

Letting TTTs = [TTT_1, ..., TTT_{n_regimes}], etc., we can then call the time- varying methods of the algorithms:

kalman_filter(regime_indices, data, TTTs, RRRs, CCCs, QQs, ZZs, DDs, EEs, z0 = Vector(), P0 = Matrix(); allout = true, n_presample_periods = 0)

hamilton_smoother(regime_indices, data, TTTs, RRRs, CCCs, QQs, ZZs, DDs, EEs, z0, P0; n_presample_periods = 0)
koopman_smoother(regime_indices, data, TTTs, RRRs, CCCs, QQs, ZZs, DDs, z0, P0, pred, vpred; n_presample_periods = 0)
carter_kohn_smoother(regime_indices, data, TTTs, RRRs, CCCs, QQs, ZZs, DDs, EEs, z0, P0; n_presample_periods = 0, draw_states = true)
durbin_koopman_smoother(regime_indices, data, TTTs, RRRs, CCCs, QQs, ZZs, DDs, EEs, z0, P0; n_presample_periods = 0, draw_states = true)

First Commit

02/06/2017

Last Touched

2 days ago

Commits

68 commits

Used By: