Key Concepts¶
What is a Dynamic Linear Model?¶
A Dynamic Linear Model (DLM) is a state-space model where both the state evolution and observation equations are linear and driven by Gaussian noise. DLMs are a flexible framework for decomposing a time series into interpretable components — trend, seasonality, regression effects, cycles — and forecasting with uncertainty.
At each time step \(t\), a DLM is defined by:
A state \(\boldsymbol{\theta}_t\) that evolves over time (e.g., the current level, slope, and seasonal effects)
An observation \(Y_t\) that is a noisy linear function of the state
The Kalman filter estimates the state given observations, and the RTS smoother refines those estimates using the full dataset.
Components and composition¶
dynaris provides six building blocks, each defining a specific structure for the state-space matrices:
Component |
State dim |
Description |
|---|---|---|
|
1 |
Random walk plus noise |
|
2 |
Level plus slope |
|
period - 1 |
Dummy or Fourier seasonal effects |
|
n_regressors | Dynamic or static coefficients |
|
|
order |
AR(p) in companion form |
|
2 |
Damped stochastic sinusoid |
Combine any of these with the + operator:
from dynaris import LocalLinearTrend, Seasonal, Cycle
model = LocalLinearTrend() + Seasonal(period=12) + Cycle(period=40, damping=0.95)
# Combined state_dim = 2 + 11 + 2 = 15
Under the hood, this builds a single StateSpaceModel with block-diagonal
system matrices (the superposition principle from West and Harrison, 1997).
The workflow¶
A typical dynaris session follows four steps:
Build — compose components into a model
Fit — run the Kalman filter on observed data
Smooth — run the RTS smoother for refined estimates
Forecast — project forward with uncertainty
from dynaris import LocalLevel, DLM
model = LocalLevel()
dlm = DLM(model)
dlm.fit(y) # Kalman filter
dlm.smooth() # RTS smoother
fc = dlm.forecast(steps=12)
dlm.plot(kind="panel")
Notation¶
dynaris follows the West and Harrison (1997) notation throughout:
Symbol |
Code |
Meaning |
|---|---|---|
F |
|
|
G |
|
|
V |
|
|
W |
|
|
For the full mathematical treatment, see Mathematical Background.
References¶
West, M. and Harrison, J. (1997). Bayesian Forecasting and Dynamic Models, 2nd edition. Springer.