Skip to main content

Cookies on Macro by Mark.We use essential cookies for sign-in, locale, and security. With your permission, we also use optional cookies for preferences, for analytics, and for advertising measurement with the Meta (Facebook) Pixel. Read our cookie policy.

Macro by MarkMacro by Mark
  • Home
Loading…
Loading…
← Models
MacroConceptsPolicyModels

Unobserved components model

State-space decomposition that separates a macro series into latent trend, cycle, seasonal, and irregular components.

OverviewGraphMathReferences

Understand the mathematics

Follow the same equations and assumptions one section at a time or in a continuous reading.

Hover or focus a symbol defined in this model to find its exact matches. Select it to keep the highlight; Escape clears the selection.

State-Space Representation of the Ucm

The UCM writes the observed series as a sum of latent components. To estimate these components, we stack their individual transition equations into a single state-space system suitable for the Kalman filter. The derivation gives the state-space matrices for the full model: local linear trend, stochastic cycle, trigonometric seasonal, and irregular.

The key insight is that each component contributes a block to the state vector and a corresponding block to the transition matrix. The measurement equation simply sums the relevant state elements. The resulting system is linear and Gaussian, so the Kalman filter produces the exact conditional mean and covariance of the latent state.

yt=μt⏟trend+ψt⏟cycle+γt⏟seasonal+εt⏟irregular,εt∼N(0,σε2)y_t = \underbrace{\mu_t}_{\text{trend}} + \underbrace{\psi_t}_{\text{cycle}} + \underbrace{\gamma_t}_{\text{seasonal}} + \underbrace{\varepsilon_t}_{\text{irregular}}, \quad \varepsilon_t \sim N(0, \sigma^2_\varepsilon)yt​=trendμt​​​+cycleψt​​​+seasonalγt​​​+irregularεt​​​,εt​∼N(0,σε2​)
μt\mu_tμt​ψt\psi_tψt​γt\gamma_tγt​εt\varepsilon_tεt​

The observation equation. Each component is latent; only yty_tyt​ is observed.

(μtβt)=(1101)(μt−1βt−1)+(ηtζt),(ηtζt)∼N ⁣(0,(ση200σζ2))\begin{pmatrix} \mu_t \\ \beta_t \end{pmatrix} = \begin{pmatrix} 1 & 1 \\ 0 & 1 \end{pmatrix} \begin{pmatrix} \mu_{t-1} \\ \beta_{t-1} \end{pmatrix} + \begin{pmatrix} \eta_t \\ \zeta_t \end{pmatrix}, \quad \begin{pmatrix} \eta_t \\ \zeta_t \end{pmatrix} \sim N\!\left(0, \begin{pmatrix} \sigma^2_\eta & 0 \\ 0 & \sigma^2_\zeta \end{pmatrix}\right)(μt​βt​​)=(10​11​)(μt−1​βt−1​​)+(ηt​ζt​​),(ηt​ζt​​)∼N(0,(ση2​0​0σζ2​​))
μt\mu_tμt​ση2\sigma^2_{\eta}ση2​σζ2\sigma^2_{\zeta}σζ2​

Local linear trend. The level μt\mu_tμt​ follows a random walk with drift βt\beta_tβt​, and the drift itself follows a random walk.

(ψtψt∗)=ρ(cos⁡λcsin⁡λc−sin⁡λccos⁡λc)(ψt−1ψt−1∗)+(κtκt∗),(κtκt∗)∼N ⁣(0,σκ2I2)\begin{pmatrix} \psi_t \\ \psi^*_t \end{pmatrix} = \rho \begin{pmatrix} \cos\lambda_c & \sin\lambda_c \\ -\sin\lambda_c & \cos\lambda_c \end{pmatrix} \begin{pmatrix} \psi_{t-1} \\ \psi^*_{t-1} \end{pmatrix} + \begin{pmatrix} \kappa_t \\ \kappa^*_t \end{pmatrix}, \quad \begin{pmatrix} \kappa_t \\ \kappa^*_t \end{pmatrix} \sim N\!\left(0, \sigma^2_\kappa I_2 \right)(ψt​ψt∗​​)=ρ(cosλc​−sinλc​​sinλc​cosλc​​)(ψt−1​ψt−1∗​​)+(κt​κt∗​​),(κt​κt∗​​)∼N(0,σκ2​I2​)
ψt\psi_tψt​ρ\rhoρλc\lambda_cλc​

Stochastic cycle. The rotation matrix generates sinusoidal dynamics at frequency λc\lambda_cλc​; the damping factor ρ\rhoρ ensures stationarity. The auxiliary state ψt∗\psi_t^*ψt​∗ is needed to produce the rotation.

For j=1,…,⌊s/2⌋:(γj,tγj,t∗)=(cos⁡λjsin⁡λj−sin⁡λjcos⁡λj)(γj,t−1γj,t−1∗)+(ωj,tωj,t∗),λj=2πjs\text{For } j = 1, \ldots, \lfloor s/2 \rfloor: \quad \begin{pmatrix} \gamma_{j,t} \\ \gamma^*_{j,t} \end{pmatrix} = \begin{pmatrix} \cos\lambda_j & \sin\lambda_j \\ -\sin\lambda_j & \cos\lambda_j \end{pmatrix} \begin{pmatrix} \gamma_{j,t-1} \\ \gamma^*_{j,t-1} \end{pmatrix} + \begin{pmatrix} \omega_{j,t} \\ \omega^*_{j,t} \end{pmatrix}, \quad \lambda_j = \frac{2\pi j}{s}For j=1,…,⌊s/2⌋:(γj,t​γj,t∗​​)=(cosλj​−sinλj​​sinλj​cosλj​​)(γj,t−1​γj,t−1∗​​)+(ωj,t​ωj,t∗​​),λj​=s2πj​

Trigonometric seasonal. Each harmonic pair (j=1,…,⌊s/2⌋)(j = 1, \ldots, \lfloor s/2 \rfloor)(j=1,…,⌊s/2⌋) rotates at frequency λj=2πj/s\lambda_j = 2 \pi j/sλj​=2πj/s. The seasonal component is γt=∑jγj,t\gamma_t = \sum_j \gamma_{j,t}γt​=∑j​γj,t​.

αt=(μtβtψtψt∗γ1,tγ1,t∗⋮),αt=T αt−1+R ξt,yt=Z αt+εt\alpha_t = \begin{pmatrix} \mu_t \\ \beta_t \\ \psi_t \\ \psi^*_t \\ \gamma_{1,t} \\ \gamma^*_{1,t} \\ \vdots \end{pmatrix}, \quad \alpha_t = T\, \alpha_{t-1} + R\, \xi_t, \quad y_t = Z\, \alpha_t + \varepsilon_tαt​=​μt​βt​ψt​ψt∗​γ1,t​γ1,t∗​⋮​​,αt​=Tαt−1​+Rξt​,yt​=Zαt​+εt​
μt\mu_tμt​ψt\psi_tψt​εt\varepsilon_tεt​

The stacked state-space form. T is the block-diagonal transition matrix, R selects the disturbance locations, Z picks out the trend level, cycle, and seasonal-sum elements. This is the system the Kalman filter operates on.

Z=(101010⋯)Z = \begin{pmatrix} 1 & 0 & 1 & 0 & 1 & 0 & \cdots \end{pmatrix}Z=(1​0​1​0​1​0​⋯​)

The measurement vector selects μt\mu_tμt​ (first element), ψt\psi_tψt​ (third element), and γ1,t,γ2,t\gamma_{1,t}, \gamma_{2,t}γ1,t​,γ2,t​, etc. (every other seasonal state). Zeros multiply the auxiliary states βt\beta_tβt​, ψt∗\psi_t^*ψt​∗ and γj,t∗\gamma_{j,t}^*γj,t∗​.

Write each component transition independently

Start from the individual component laws of motion as defined by Harvey (1989).
Trend: Tμ=(1101),Cycle: Tψ=ρ(cos⁡λcsin⁡λc−sin⁡λccos⁡λc),Seasonal harmonic j:Tγj=(cos⁡λjsin⁡λj−sin⁡λjcos⁡λj)\text{Trend: } T_{\mu} = \begin{pmatrix} 1 & 1 \\ 0 & 1 \end{pmatrix}, \quad \text{Cycle: } T_{\psi} = \rho \begin{pmatrix} \cos\lambda_c & \sin\lambda_c \\ -\sin\lambda_c & \cos\lambda_c \end{pmatrix}, \quad \text{Seasonal harmonic } j: T_{\gamma_j} = \begin{pmatrix} \cos\lambda_j & \sin\lambda_j \\ -\sin\lambda_j & \cos\lambda_j \end{pmatrix}Trend: Tμ​=(10​11​),Cycle: Tψ​=ρ(cosλc​−sinλc​​sinλc​cosλc​​),Seasonal harmonic j:Tγj​​=(cosλj​−sinλj​​sinλj​cosλj​​)
ρ\rhoρλc\lambda_cλc​

Stack into block-diagonal transition matrix T

Components are driven by independent disturbances, so their transitions are block-diagonal.
T=blkdiag ⁣(Tμ,  Tψ,  Tγ1,  …,  Tγ⌊s/2⌋)T = \text{blkdiag}\!\left(T_{\mu},\; T_{\psi},\; T_{\gamma_1},\; \ldots,\; T_{\gamma_{\lfloor s/2 \rfloor}}\right)T=blkdiag(Tμ​,Tψ​,Tγ1​​,…,Tγ⌊s/2⌋​​)

Form the disturbance covariance matrix Q

Mutual independence of component disturbances gives a block-diagonal Q.
Q=blkdiag ⁣((ση200σζ2),  σκ2I2,  σω12I2,  …,  σω⌊s/2⌋2I2)Q = \text{blkdiag}\!\left(\begin{pmatrix} \sigma^2_\eta & 0 \\ 0 & \sigma^2_\zeta \end{pmatrix},\; \sigma^2_\kappa I_2,\; \sigma^2_{\omega_1} I_2,\; \ldots,\; \sigma^2_{\omega_{\lfloor s/2 \rfloor}} I_2 \right)Q=blkdiag((ση2​0​0σζ2​​),σκ2​I2​,σω1​2​I2​,…,σω⌊s/2⌋​2​I2​)
ση2\sigma^2_{\eta}ση2​σζ2\sigma^2_{\zeta}σζ2​

Construct the measurement vector Z

The observation picks out the first state from each component block (level, cycle, and each seasonal harmonic's cosine term).
Z=(1,0,1,0,1,0,1,0,…)Z = (1, 0, 1, 0, 1, 0, 1, 0, \ldots)Z=(1,0,1,0,1,0,1,0,…)

Specify measurement noise variance

The irregular enters only through the observation equation.
H=σε2H = \sigma^2_\varepsilonH=σε2​

State dimension count

Verify the total state dimension for implementation. The seasonal block as written carries 2⌊s/2⌋2 \lfloor s/2 \rfloor2⌊s/2⌋ states, but for even sss the Nyquist harmonic's companion state γs/2,t∗\gamma^*_{s/2,t}γs/2,t∗​ is redundant, so the minimal seasonal dimension is s−1s - 1s−1.
m=2  (trend)+2  (cycle)+2⌊s/2⌋  (seasonal, full pairs)=4+2⌊s/2⌋,minimal seasonal dimension=s−1m = 2 \;(\text{trend}) + 2 \;(\text{cycle}) + 2 \lfloor s/2 \rfloor \;(\text{seasonal, full pairs}) = 4 + 2\lfloor s/2 \rfloor, \quad \text{minimal seasonal dimension} = s - 1m=2(trend)+2(cycle)+2⌊s/2⌋(seasonal, full pairs)=4+2⌊s/2⌋,minimal seasonal dimension=s−1

Diffuse initialization for non-stationary components

The trend level and slope are non-stationary (unit root), and the trigonometric seasonal rotation has unit-modulus roots, so it is non-stationary as well: level, slope, and seasonal states all receive diffuse initial covariances. Only the damped cycle (ρ<1)(\rho < 1)(ρ<1) is stationary and starts from its unconditional distribution.
P0,μ=κI2  (κ→∞),P0,γj=κI2  (κ→∞),P0,ψ=σκ21−ρ2I2P_{0,\mu} = \kappa I_2 \;(\kappa \to \infty), \quad P_{0,\gamma_j} = \kappa I_2 \;(\kappa \to \infty), \quad P_{0,\psi} = \frac{\sigma^2_\kappa}{1 - \rho^2} I_2P0,μ​=κI2​(κ→∞),P0,γj​​=κI2​(κ→∞),P0,ψ​=1−ρ2σκ2​​I2​

UCM-to-ARIMA mapping

Every UCM implies a reduced-form ARIMA(p,d,q)\text{ARIMA}(p,d,q)ARIMA(p,d,q) for yty_tyt​. The local linear trend + irregular gives ARIMA(0,2,2). Adding a cycle gives ARIMA(2,2,4) under typical parameterizations. This mapping is many-to-one: the UCM imposes structure that the ARIMA does not.

State dimension for quarterly data

With s=4s = 4s=4: m=2+2+2×2=8m = 2 + 2 + 2 \times 2 = 8m=2+2+2×2=8 (trend, cycle, and the seasonal harmonics at j=1,2j = 1, 2j=1,2) when full pairs are carried; dropping the redundant Nyquist companion (j=2j = 2j=2 for s=4s = 4s=4) gives the minimal seasonal dimension s−1=3s - 1 = 3s−1=3 and m=7m = 7m=7. For monthly data (s=12s = 12s=12): m=2+2+2×6=16m = 2 + 2 + 2 \times 6 = 16m=2+2+2×6=16 with full pairs, or m=2+2+11=15m = 2 + 2 + 11 = 15m=2+2+11=15 minimal.

Transition checks

Sampled dynamics
zt=G(zt−1;θ)+ηt,yt=Hzt+εtz_t=G(z_{t-1};\theta)+\eta_t,\qquad y_t=H z_t+\varepsilon_tzt​=G(zt−1​;θ)+ηt​,yt​=Hzt​+εt​
εt\varepsilon_tεt​

The state is updated at observed dates. A line between dates is a display convention unless the model specifies behavior inside the interval.

Read adjacent points as adjacent sample calculations. Smoothness is a property of the estimator, not of the chart line.

Do not infer within-period behavior from a sampled estimator.

Variable timing

Latent state

zt=G(zt−1;θ)+ηtz_t=G(z_{t-1};\theta)+\eta_tzt​=G(zt−1​;θ)+ηt​

The state updates at sample dates. The visible line is only as smooth as the estimated state sequence.

Observation equation

yt=Hzt+εty_t=Hz_t+\varepsilon_tyt​=Hzt​+εt​
εt\varepsilon_tεt​

Observed series can move differently from latent states because measurement noise and loadings matter.

Proof lineage

Typed relationships across models

Parents -- models this proof draws from

Imports fromKalman Filter·PREDICTION STEP (TIME UPDATE)The UCM uses the Kalman filter as its estimation engine. The prediction-update recursion and the innovation likelihood are imported directly from the Kalman filter framework.

Keep going

Read next

Continue with a related concept, model, or example.

Theory model

IS-LM Model

a well-connected theoretical model two steps from here

New angle: theoretical model →
Macro by Mark
Help
Privacy PolicyTerms of UseEthics and Compliance

© 2026 Mark Jayson Nation LLC