Quant Memo
Core

The Hodrick-Prescott Filter

A widely used method for splitting a time series into a smooth long-run trend and a short-run cyclical component, controlled by a single smoothness parameter that trades off how closely the trend follows the data.

Prerequisites: Trend-Stationary Versus Difference-Stationary Series

GDP data wiggles up and down every quarter, but economists usually want to talk about two separate things: the underlying long-run growth path (the trend), and how far the economy currently sits above or below that path (the cycle — is it a boom or a recession?). Simply drawing a straight line through the data is too rigid for a growth path that itself bends over decades; simply smoothing with a short moving average lets too much short-term noise leak into what should be a clean trend. The Hodrick-Prescott (HP) filter is a specific, mathematically defined way to split a series into these two pieces, with one dial that controls exactly how flexible the trend line is allowed to be.

An analogy: bending a flexible ruler through the data

Imagine physically bending a flexible plastic ruler so it passes as close as possible to a scatter of data points, but the ruler resists being bent too sharply — it wants to stay smooth and straight where it can. Pull it too rigidly straight and it ignores real, gradual shifts in the data; let it bend too freely and it just tracks every bump, ceasing to be a "trend" at all and becoming indistinguishable from the noisy data itself. The HP filter is exactly this flexible ruler, with a stiffness dial: turning the dial up makes the ruler more rigid (a smoother, slower-moving trend); turning it down lets the ruler bend more freely (a trend that hugs the data more closely, leaving less for the cycle to explain).

The mechanics, one symbol at a time

The HP filter splits the observed series yty_t into a trend τt\tau_t and a cyclical component ct=ytτtc_t = y_t - \tau_t, choosing the trend to minimize:

t=1T(ytτt)2+λt=2T1[(τt+1τt)(τtτt1)]2.\sum_{t=1}^{T} (y_t - \tau_t)^2 + \lambda \sum_{t=2}^{T-1} \big[(\tau_{t+1} - \tau_t) - (\tau_t - \tau_{t-1})\big]^2.

The first sum is the total squared gap between the actual data and the trend — how well the trend fits the data. The second sum penalizes the trend's curvature — how much the trend's slope changes from one period to the next — so a trend that suddenly bends sharply gets penalized. λ\lambda (lambda) is the single smoothness dial: at λ=0\lambda = 0 there's no curvature penalty at all, so the trend simply equals the data exactly (every wiggle becomes "trend," leaving zero cycle); as λ\lambda \to \infty, curvature is punished infinitely, forcing the trend toward a single straight line. In plain English: the filter finds the smoothest possible trend line that still stays reasonably close to the actual data, with λ\lambda setting the exchange rate between "closeness to data" and "smoothness of trend." The commonly cited default is λ=1600\lambda = 1600 for quarterly data, though this specific number is itself a source of ongoing debate.

Worked example 1: two lambdas on the same series

Suppose quarterly GDP index values run {100,102,99,105,104,108}\{100, 102, 99, 105, 104, 108\}. With a very small λ\lambda (say 1), the fitted trend tracks the data closely, producing something like {100.5,101.8,100.2,103.9,104.6,107.2}\{100.5, 101.8, 100.2, 103.9, 104.6, 107.2\} — the cyclical component (data minus trend) stays small, roughly ±1\pm 1 to ±2\pm 2 points, meaning most of the series' movement is classified as "trend," leaving little for the cycle to explain. With a large λ\lambda (say 100,000), the trend flattens to something close to a straight line, roughly {100.5,102.0,103.5,105.0,106.5,108.0}\{100.5, 102.0, 103.5, 105.0, 106.5, 108.0\} — now the cyclical component swings much more, for instance quarter 3's actual (99) minus this flatter trend (103.5) gives a cycle reading of 4.5-4.5, a much larger "below trend" signal than the low-λ\lambda version gave. The same raw data can support very different "how far below trend is the economy right now" conclusions purely from the choice of λ\lambda.

Worked example 2: reading a cycle signal for a trading decision

Suppose a commodity-linked equity index's HP-filtered cyclical component currently reads ct=3.2%c_t = -3.2\% (the index sits 3.2% below its smooth long-run trend) with a historical standard deviation of cyclical deviations of about 2%. A mean-reversion strategy interpreting this as "1.6 standard deviations below trend" might read this as an oversold signal worth a long position, betting on reversion toward the trend line — but only if the trend itself is trustworthy, which depends heavily on the λ\lambda chosen and, as the warning below explains, on whether the most recent data points are stable.

low λ (green) high λ (red, flatter) raw data (grey)
A low-λ trend hugs the raw data closely; a high-λ trend is flatter and less responsive — the same data, two very different views of "where the economy is trending."
low λ: small cycle swings high λ: large cycle swings
The stiffer (high-λ) trend leaves a larger residual for the cyclical component to absorb — the same data produces a much bigger "output gap" reading depending on the smoothness dial.

What this means in practice

The HP filter is a standard, quick way to extract a business-cycle or trend-cycle decomposition from macro or price series without fitting a full structural model, and it's widely used to construct "gap" measures (output gap, valuation gap) for regime and mean-reversion signals. It sits alongside changepoint detection (see Changepoint Detection and CUSUM) as a way to characterize how a series' level is behaving over time, though the two answer different questions — smooth decomposition versus discrete break detection.

The HP filter splits a series into a smooth trend and a residual cycle by minimizing a tradeoff between fit-to-data and trend-curvature, controlled entirely by one smoothing parameter λ — and because that choice is somewhat arbitrary, the resulting "trend" and "how far above/below trend we are" readings are not unique facts about the data but conclusions conditional on that choice.

The HP filter has a well-documented end-of-sample problem: because the trend at the very last data point is estimated with much less future information than trend estimates in the middle of the sample, the most recent cyclical readings — exactly the ones a trader cares about most for a current signal — are the least reliable and get revised substantially as new data arrives. Treating today's HP-filtered "output gap" or "cyclical deviation" as a stable, final number is a common mistake; it should be understood as a preliminary estimate likely to shift once more data comes in.

Related concepts

Practice in interviews

Further reading

  • Hodrick and Prescott, Postwar U.S. Business Cycles, Journal of Money, Credit and Banking
  • Hamilton, Why You Should Never Use the Hodrick-Prescott Filter, Review of Economics and Statistics
ShareTwitterLinkedIn