Objective
The ARMA and GARCH lessons modelled the observed series directly. Many quantities a researcher cares about are never observed: the "true" price under microstructure noise, a fair-value spread, a drifting hedge ratio, a latent factor. A state-space model separates what is hidden (the state) from what is measured (the observation). This lesson sets up the framework and the standard rewrites; the next lesson filters it.
The two equations
The linear Gaussian state-space model has a state vector (dimension ) and observations (dimension ):
with and independent of each other and over time. is the transition matrix, the design (loading) matrix, and the state and observation noise covariances. Any of the matrices may vary with as long as they are known at time ; a time-varying is what makes time-varying regressions possible.
Two facts follow directly:
- The state is Markov. Everything the past says about the future passes through . That is what makes a one-step recursive filter possible.
- Stationarity is about . If every eigenvalue of has modulus below 1, the state has a stationary distribution with mean and covariance solving the discrete Lyapunov equation (take the variance of both sides of the state equation). With a unit eigenvalue (random-walk states) there is no stationary distribution and the filter needs a diffuse start.
The representation is not unique: any invertible change of variables gives an observationally equivalent model. So the state has meaning only through the structure you impose on it.
Standard forms
AR(): the companion form. Stack the last values into the state. For AR(2), :
The second row only shifts down. The eigenvalues of are the inverse roots of , so "stationary iff eigenvalues inside the unit circle" is the same condition as in the ARMA lesson. All the noise is in the state; the observation is exact.
ARMA(1,1). fits in a two-dimensional state:
Check the first row: . In general an ARMA() needs a state of dimension . This is how statsmodels' SARIMAX computes exact ARMA likelihoods, with missing values handled for free.
Local level (random walk plus noise). The workhorse for a noisy, drifting quantity:
Scalar state, . Everything depends on the signal-to-noise ratio . With the level is a constant and the best estimate is the sample mean; with the series is an exactly observed random walk and the best estimate is the latest observation. Adding a slope state (, ) gives the local linear trend.
Time-varying regression. Let the coefficients be the state and the regressors the design:
So , changes every period, and sets how fast the intercept and beta may drift. With the coefficients are constant and the filter reproduces recursive (expanding-window) OLS. A positive discounts old data smoothly, replacing the arbitrary window length of rolling OLS with a parameter that can be estimated by maximum likelihood. The last lesson of this module uses it for a hedge ratio.
Worked example
the AR(2) companion form and its stationary covariance
Write () in companion form. Is it stationary? Find and from the Lyapunov equation, and check against Yule–Walker.
Show solutionHide solution
Form. , , .
Stationarity. The characteristic equation of is , so and . Both are inside the unit circle: stationary.
Stationary covariance. Write (both state entries have the same variance). Multiplying out :
- Entry (1,2): , so .
- Entry (1,1): . Substituting, , so .
Hence and . Yule–Walker agrees: , , .
In code, the Lyapunov equation is one call:
import numpy as np
from scipy.linalg import solve_discrete_lyapunov
# AR(2) X_t = 0.9 X_{t-1} - 0.2 X_{t-2} + e_t, sigma^2 = 1, in companion form
T = np.array([[0.9, -0.2],
[1.0, 0.0]])
RQR = np.array([[1.0, 0.0],
[0.0, 0.0]])
print("eigenvalues:", np.linalg.eigvals(T))
P = solve_discrete_lyapunov(T, RQR) # solves P = T P T' + RQR'
print(np.round(P, 4))
print("rho1 =", round(P[0, 1] / P[0, 0], 4))
Output:
eigenvalues: [0.5 0.4]
[[2.381 1.7857]
[1.7857 2.381 ]]
rho1 = 0.75
The same call gives the stationary covariance of any stationary state, which is how a filter is initialised for stationary components.
Worked example
what the local level model implies for the data
For the local level model with and , find the autocorrelation function of . Which ARIMA model is this, and what are its MA coefficient and innovation variance?
Show solutionHide solution
Difference the observation equation: .
- .
- (only is shared).
- Covariances at lag 2 and beyond are zero.
So is an MA(1) with , and is an ARIMA(0,1,1). Solve , i.e. ; the invertible root is . The innovation variance follows from : .
Two lessons from this:
- always lies in : the local level model can only produce negative first-order autocorrelation in changes, the signature of noise around a random walk (bid–ask bounce on a mid-price is the classic case). If the data show positive in changes, this model is wrong for them.
- The ARIMA(0,1,1) forecast is exponential smoothing with weight on the newest observation. The next lesson derives the same number as the steady-state Kalman gain, and as the steady-state innovation variance: the two descriptions are the same model.
Why bother with state space
- One algorithm for everything. Once a model is in this form, the Kalman filter gives filtered states, forecasts with error variances, and the exact Gaussian likelihood. Estimation is then numerical optimisation over the few parameters in .
- Missing and irregular data. A missing observation means skipping the update step; the prediction step carries the state forward. No interpolation, no dropping rows.
- Interpretability. Components (level, trend, cycle, seasonal, time-varying beta) are explicit states you can plot, rather than implied by ARMA coefficients.
Limits. Linear-Gaussian structure is an assumption: fat-tailed noise makes the filter over-react to outliers, and nonlinear observation equations (prices observed through an option pricing formula, say) need extended or unscented filters or particle filters. Parameters such as are often weakly identified in short samples, and the likelihood can pile up at .
In an interview
"Put X in state-space form" is a standard question. Say out loud what the state is (the smallest set of quantities that makes the future independent of the past), then write , , and say which noise lives where. Check the first row reproduces the model. Mention that stationarity is read from the eigenvalues of .
Knowledge check
In the local level model , , what is the lag-1 autocorrelation of when and ?
Knowledge check
You write a regression with a drifting intercept and beta in state-space form. What are the transition matrix T and the design Z_t?
Knowledge check
An AR(3) is written in companion form. Which statement is correct?
Key takeaways
- State equation , observation ; the state is Markov and stationarity is read from the eigenvalues of .
- The stationary state covariance solves .
- AR() uses the companion form; ARMA() needs a state of size ; the local level is random walk plus noise; a time-varying regression has and .
- The local level model equals ARIMA(0,1,1) with ; its behaviour is governed by the signal-to-noise ratio .
- State space buys one filter for likelihood, forecasts and missing data, at the price of linear-Gaussian assumptions and often weakly identified variance parameters.
Practice problems
Finished reading?
Answer the 3 knowledge checks to complete this lesson (0 done).