State Space Models in Python
Project description
State Space
State Space is a Python package that permits the symbolic specification of linear state space models with normally distributed innovations and measurement errors. Coefficients are defined via SymPy matrices which are then compiled into a numerical statsmodels implementation. These unobserved state is inferred via Kalman filtering and model parameters are estimated via maximum likelihood using statsmodels as the numerical backend.
Stochastic Process
A linear state space model consists of a state evolution equation and an observation equation. The state is not directly observed, instead a linear transformation of the state with added Gaussian noise is observed. In a linear state space model, the state evolves according to
,
where the coefficients T, c, and R may depend on exogenous variables but not on the state itself. They may involve parameters that must be estimated from the data. The state innovation \eta_t has a multivariate normal distribution with zero mean and covariance matrix Q, which may depend on exogenous variables but not the state itself.
The observation equation maps the unobserved state according to
.
The observation noise \epsilon_t has a multivariate normal distribution with zero mean and covariance matrix H. The coefficients Z, d, as well as H may depend on exogeneous data and involve unknown parameters that are estimated via MLE.
State Space adopts the following terminology:
T: transition matrix
c: state intercept vector
R: selection matrix
Q: state covariance matrix
Z: design matrix
d: observation intercept
H: observation covariance matrix
The coefficients T,c, R, Q, Z, d, H are specified as SymPy matrices and may involve unknown parameters and exogenous data.
Examples
State Space includes two examples in Jupyter notebooks:
1.) A conditional linear factor model for returns of the Ford motor corporation with S&P 500 returns as the factor.
2.) A model of time-variation in the equity premium applied to S&P 500 index data.
Installation
pip install state_space
or
pip3 install state_space
if not using Anaconda.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for state_space-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7ea3b2f85a7b855a7e11afa8ef3edb214bc1d5eb4b1b4b93646aeb65a3329f49 |
|
MD5 | 31317e6200cc57b160b6fd399d7a98b9 |
|
BLAKE2b-256 | 9d1a21e67244e5849bed8c3ca28cb56285a0f03a9ac81003d0411a01fcc46b0d |