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

HP filter and Beveridge-Nelson decomposition Model

Trend-cycle decomposition for a single macro series, comparing smooth HP trend extraction with Beveridge-Nelson permanent-transitory decomposition.

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.

Hp Filter AS Penalized Least Squares

The HP filter's objective function trades off fidelity to the data against smoothness of the trend. The derivation gives the closed-form solution, shows that it is a symmetric linear filter, and characterizes its frequency-response function.

The derivation proceeds in three steps: write the objective, take the first-order condition, and solve the resulting banded linear system. The key insight is that the roughness penalty translates into a specific band-limited filter in the frequency domain.

min⁡{τt}t=1T{∑t=1T(yt−τt)2+λ∑t=3T[(τt−τt−1)−(τt−1−τt−2)]2}\min_{\{\tau_t\}_{t=1}^T} \left\{ \sum_{t=1}^{T} (y_t - \tau_t)^2 + \lambda \sum_{t=3}^{T} [(\tau_t - \tau_{t-1}) - (\tau_{t-1} - \tau_{t-2})]^2 \right\}{τt​}t=1T​min​{t=1∑T​(yt​−τt​)2+λt=3∑T​[(τt​−τt−1​)−(τt−1​−τt−2​)]2}
λ\lambdaλ

The HP objective. The first term penalizes deviation from the data. The second term penalizes curvature (second differences) of the trend. λ\lambdaλ controls the trade-off.

min⁡τ{(y−τ)′(y−τ)+λ τ′K′K τ}\min_{\tau} \left\{ (y - \tau)^\prime (y - \tau) + \lambda\, \tau^\prime K^\prime K\, \tau \right\}τmin​{(y−τ)′(y−τ)+λτ′K′Kτ}
λ\lambdaλKKK

Matrix form. KKK is the (T−2)×T(T-2) \times T(T−2)×T second-difference operator, so KτK \tauKτ extracts (τ3−2τ2+τ1,τ4−2τ3+τ2,…)(\tau_3 - 2 \tau_2 + \tau_1, \tau_4 - 2 \tau_3 + \tau_2, \ldots)(τ3​−2τ2​+τ1​,τ4​−2τ3​+τ2​,…).

−2(y−τ)+2λK′Kτ=0⟹(IT+λK′K) τ=y-2(y - \tau) + 2\lambda K^\prime K \tau = 0 \quad \Longrightarrow \quad (I_T + \lambda K^\prime K)\,\tau = y−2(y−τ)+2λK′Kτ=0⟹(IT​+λK′K)τ=y
λ\lambdaλKKK

First-order condition. The solution is a linear function of the data.

τ^HP=(IT+λK′K)−1 y\hat{\tau}^{HP} = (I_T + \lambda K^\prime K)^{-1}\, yτ^HP=(IT​+λK′K)−1y
λ\lambdaλKKK

Closed-form solution. The matrix (I+λK′K)(I + \lambda K'K)(I+λK′K) is symmetric, positive definite, and banded (bandwidth 5), so it can be solved in O(T)O(T)O(T) operations by banded Cholesky.

c^HP=y−τ^HP=[IT−(IT+λK′K)−1]y=λK′K(IT+λK′K)−1 y\hat{c}^{HP} = y - \hat{\tau}^{HP} = \left[I_T - (I_T + \lambda K^\prime K)^{-1}\right] y = \lambda K^\prime K (I_T + \lambda K^\prime K)^{-1}\, yc^HP=y−τ^HP=[IT​−(IT​+λK′K)−1]y=λK′K(IT​+λK′K)−1y
λ\lambdaλKKK

The cyclical component is also a linear filter applied to y. Its gain is large at business-cycle frequencies and small at trend frequencies.

gHP(ω)=4λ(1−cos⁡ω)21+4λ(1−cos⁡ω)2g_{HP}(\omega) = \frac{4\lambda(1 - \cos\omega)^2}{1 + 4\lambda(1 - \cos\omega)^2}gHP​(ω)=1+4λ(1−cosω)24λ(1−cosω)2​
λ\lambdaλ

Frequency-response (gain) of the HP cycle-extraction filter for an infinite sample. At ω=0\omega = 0ω=0 (trend frequency), the gain is zero. At ω=π\omega = \piω=π (highest frequency), the gain approaches 1. The half-power frequency depends on λ\lambdaλ.

Write the second-difference operator as a matrix

Express the roughness penalty in matrix notation for the FOC.
K=(1−210⋯01−21⋯⋱⋱⋱)∈R(T−2)×TK = \begin{pmatrix} 1 & -2 & 1 & 0 & \cdots \\ 0 & 1 & -2 & 1 & \cdots \\ & & \ddots & \ddots & \ddots \end{pmatrix} \in \mathbb{R}^{(T-2) \times T}K=​10​−21​1−2⋱​01⋱​⋯⋯⋱​​∈R(T−2)×T
KKK

Take the first-order condition

Differentiate the objective with respect to the TTT-vector τ\tauτ and set to zero.
∂∂τ[(y−τ)′(y−τ)+λτ′K′Kτ]=−2(y−τ)+2λK′Kτ=0\frac{\partial}{\partial \tau} \left[ (y - \tau)^\prime(y - \tau) + \lambda \tau^\prime K^\prime K \tau \right] = -2(y - \tau) + 2\lambda K^\prime K \tau = 0∂τ∂​[(y−τ)′(y−τ)+λτ′K′Kτ]=−2(y−τ)+2λK′Kτ=0
λ\lambdaλKKK

Solve the normal equation

Rearrange to isolate τ\tauτ. The system matrix is symmetric positive definite.
(IT+λK′K)τ^=y⟹τ^=(IT+λK′K)−1y(I_T + \lambda K^\prime K) \hat{\tau} = y \quad \Longrightarrow \quad \hat{\tau} = (I_T + \lambda K^\prime K)^{-1} y(IT​+λK′K)τ^=y⟹τ^=(IT​+λK′K)−1y
λ\lambdaλKKK

Verify positive definiteness

Both ITI_TIT​ and λK′K\lambda K'KλK′K are positive semidefinite, and ITI_TIT​ is strictly positive definite, so the sum is strictly positive definite and invertible.
x′(IT+λK′K)x=∥x∥2+λ∥Kx∥2>0∀ x≠0x^\prime (I_T + \lambda K^\prime K) x = \|x\|^2 + \lambda \|Kx\|^2 > 0 \quad \forall\, x \neq 0x′(IT​+λK′K)x=∥x∥2+λ∥Kx∥2>0∀x=0
λ\lambdaλKKK

Derive the cycle-extraction filter

The cycle is the residual from the trend. Express it as a linear filter on y.
c^=y−τ^=[I−(I+λK′K)−1]y=λK′K(I+λK′K)−1y\hat{c} = y - \hat{\tau} = [I - (I + \lambda K^\prime K)^{-1}] y = \lambda K^\prime K (I + \lambda K^\prime K)^{-1} yc^=y−τ^=[I−(I+λK′K)−1]y=λK′K(I+λK′K)−1y
λ\lambdaλKKK

Compute the frequency response for infinite T

On an infinite sample, K′KK'KK′K acts as the filter (1−L)2(1−L−1)2(1 - L)^2(1 - L^{-1})^2(1−L)2(1−L−1)2. The frequency response of the trend-extraction filter is 1/[1+4λ(1−cos⁡ω)2]1/[1 + 4 \lambda (1 - \cos \omega)^2]1/[1+4λ(1−cosω)2].
gtrend(ω)=11+4λ(1−cos⁡ω)2,gcycle(ω)=1−gtrend(ω)g_{\text{trend}}(\omega) = \frac{1}{1 + 4\lambda(1 - \cos\omega)^2}, \quad g_{\text{cycle}}(\omega) = 1 - g_{\text{trend}}(\omega)gtrend​(ω)=1+4λ(1−cosω)21​,gcycle​(ω)=1−gtrend​(ω)
λ\lambdaλ

Identify the half-power frequency

The frequency where the cycle gain equals 0.5 determines which periodicities are split between trend and cycle.
gcycle(ω∗)=0.5⟹4λ(1−cos⁡ω∗)2=1⟹ω∗=arccos⁡ ⁣(1−12λ)g_{\text{cycle}}(\omega^*) = 0.5 \quad \Longrightarrow \quad 4\lambda(1 - \cos\omega^*)^2 = 1 \quad \Longrightarrow \quad \omega^* = \arccos\!\left(1 - \frac{1}{2\sqrt{\lambda}}\right)gcycle​(ω∗)=0.5⟹4λ(1−cosω∗)2=1⟹ω∗=arccos(1−2λ​1​)
λ\lambdaλ

Banded structure and O(T) computation

K′KK'KK′K is a pentadiagonal (bandwidth 5) symmetric matrix. Banded Cholesky factorization solves the HP filter in O(T)O(T)O(T) operations, making it computationally trivial even for very long series.

End-point bias

At t=1t = 1t=1 and t=Tt = Tt=T, the filter weights are asymmetric because there are no data beyond the sample boundary. The trend estimate at the endpoints is effectively one-sided and revises substantially as new data arrive. This is the HP filter's most criticized property.

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​
θ\thetaθ

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​
θ\thetaθ

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​

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

Special case ofUnobserved Components Model·STATE-SPACE REPRESENTATION OF THE UCMThe HP filter is a special case of the UCM (I(2) trend, white-noise cycle, zero correlation). The BN decomposition corresponds to the UCM with maximally correlated trend-cycle shocks. Both are nested within the general UCM framework.Imports fromKalman Filter·PREDICTION STEP (TIME UPDATE)The Wiener-Kolmogorov interpretation of the HP filter connects it to the Kalman filter's signal-extraction logic. The BN decomposition via correlated-components UCM is estimated by the Kalman filter.

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