AI Glossary / Statistics and probability / Intermediate

Hodrick - Prescott filter

Definition

The Hodrick - Prescott filter is a time-series smoothing method that separates a series into a smooth trend and a residual commonly called the cycle. It chooses the trend by balancing closeness to the observations against a penalty on changes in the trend's slope. The smoothing parameter controls that balance; the resulting components are model-dependent decompositions, not directly observed economic quantities.

What it means

A series can rise over time while fluctuating around its broader direction. The HP filter offers one mathematical way to draw a smooth path through it and measure departures from that path.
Calling the remainder a cycle does not prove that it represents a genuine recurring mechanism. Its appearance depends on the smoothing rule, parameter choice, sample endpoints, and data-generating process. The method is widely associated with macroeconomic trend-cycle analysis, but its limitations matter in any application.

How it works

For observations y_t, choose trend values tau_t to minimize the sum of squared deviations (y_t - tau_t)² plus lambda times the sum of squared second differences (tau_(t+1) - 2*tau_t + tau_(t-1))². The second-difference terms apply only where neighboring trend values exist.
The first part rewards following the data closely. The second discourages abrupt changes in slope. Lambda is nonnegative. With lambda = 0, the trend follows the observations exactly and the residual is zero. As lambda becomes very large for a fixed finite series, the fitted trend approaches the least-squares straight line.
Once the trend is obtained, the cycle is y_t - tau_t. The standard full-sample procedure uses observations on both sides of interior dates. A historical trend estimate can therefore change when later data are added, even if the earlier raw observations are unchanged.
A conventional quarterly value is 1600. Frequency-adjustment proposals include 6.25 for annual data and 129600 for monthly data. These are conventions or suggested scaling choices, not universal evidence-based settings for every series. State and investigate the chosen value.
The usual formulation treats observations as equally spaced. Missing periods, changing measurement definitions, seasonality, and structural breaks require attention before interpreting a smooth trend. The HP filter is not automatically a seasonal adjustment procedure.
Endpoint estimates are especially sensitive because they have less surrounding information. A retrospective decomposition using future observations should not be used as though it had been available in real time. Forecast evaluation must reproduce the information available at each historical decision date.
Research has also shown that the filter can create misleading dynamic relationships in some settings. Evaluate whether the decomposition serves the substantive question and compare reasonable alternatives, such as explicit structural time-series models or other detrending approaches.
The output alone supplies neither causal interpretation nor universal confidence bands. Uncertainty and downstream inference require a stated statistical model or another appropriate assessment, rather than treating the smooth line as known truth.

Three practical examples

  • An analyst uses an HP decomposition as one descriptive view of a long aggregate activity series.
  • A business researcher compares how different smoothing choices change the apparent gap between observed demand and a trend.
  • An AI forecasting team audits whether a retrospectively filtered input accidentally includes future information.

Think of it this way

Think of drawing a flexible ruler through a noisy series. A small penalty lets it bend sharply toward individual points; a large penalty keeps it straighter. The ruler's stiffness helps determine the result, so the curve is not an assumption-free discovery.

Worked example

Use a three-observation illustration y = (0, 3, 0) and lambda = 1. There is only one second difference, tau1 - 2*tau2 + tau3. This miniature example explains the optimization, not practical time-series analysis.
The minimizing trend is (6/7, 9/7, 6/7), approximately (0.8571, 1.2857, 0.8571). The cycle is y minus trend: (-6/7, 12/7, -6/7), approximately (-0.8571, 1.7143, -0.8571).
The sum of squared cycle values is 216/49. The trend's second difference is -6/7, whose square is 36/49. Total objective value is therefore 252/49 = 36/7, approximately 5.1429.
Following the raw data exactly would give zero squared residual error but a second difference of -6, producing objective 36. A constant trend of 1 would give zero curvature penalty but squared error 1 + 4 + 1 = 6. The optimal compromise has lower objective than either candidate.
The example also shows why a positive central residual is created by the decomposition. It does not establish that the original three values contain a meaningful business cycle or that lambda = 1 is appropriate elsewhere.

Illustrative case study

Fictional case: Elm Planning adds an HP trend to a monthly demand dashboard. Managers initially interpret the latest deviation as a stable signal that demand is above its long-run level.
The analyst reruns the decomposition using successive historical data vintages and finds that endpoint estimates move as new months arrive. The team also compares several smoothing choices and checks whether seasonal patterns were handled consistently.
Elm labels the chart as a descriptive decomposition and separates retrospective analysis from information available for live planning. Decisions incorporate actual orders and forecast uncertainty rather than relying on the latest filtered gap alone.

Common misconceptions and mistakes

Common mistakes include treating the cycle as an observed structural quantity, assuming a default lambda is universally correct, and interpreting the filter as a forecasting algorithm. It estimates a decomposition; forecasting requires additional choices.
Another mistake is filtering the entire dataset before splitting it for chronological prediction tests. That can expose training-period features to future observations. Seasonal adjustment, trend smoothing, and causal analysis remain distinct tasks.

Business use

The HP filter can provide a reproducible descriptive smoothing rule, but its value depends on the question and sensitivity checks. A business report should show the raw series, specify lambda and data frequency, explain endpoint revisions, and distinguish an illustrative trend from a validated estimate of underlying capacity or demand.

People also ask

Does a larger lambda make the trend smoother?

Yes, by penalizing changes in slope more strongly.

Is the residual necessarily periodic?

No.

Can past trend estimates change with new data?

Yes, for the standard full-sample procedure.

Check your understanding

What happens at lambda = 0?

Answer: The trend equals the observations.

What is the middle cycle value in the example?

Answer: 12/7.

Why is a full-sample trend unsuitable as an unqualified real-time input?

Answer: It can use observations that were still in the future at the decision date.

Related terms

  • Seasonal adjustment
  • Trend-cycle decomposition
  • smoothing parameter
  • second difference
  • endpoint effect
  • look-ahead bias
  • structural time series
  • detrending

Learn next

Compare HP results across smoothing parameters and expanding data vintages. Then study explicit trend models and evaluate how preprocessing choices affect chronological forecasting tests.

More in Statistics and probability

  • High-dimensional statistics - High-dimensional statistics studies estimation, prediction, and inference when the number of variables or model parameters is large relative to the...
  • High frequency data - High frequency data are observations recorded at short time intervals relative to the process being studied.
  • Higher order interaction - A higher order interaction is a statistical interaction involving three or more predictors or factors.
  • Hoeffding's independence test - Hoeffding's independence test is a nonparametric procedure for assessing whether two random variables are independent, using ranks from paired observations.
  • Holm - Bonferroni method - The Holm - Bonferroni method is a step-down multiple-testing procedure that controls the family-wise error rate: the probability of rejecting at least one...
  • Homogeneity of regression - Homogeneity of regression usually means equality of the covariate regression slopes across groups in a common-slope analysis of covariance model.

Sources

Statsmodels, HP filter documentation: https://www.statsmodels.org/stable/generated/statsmodels.tsa.filters.hp_filter.hpfilter.html James Hamilton, Why You Should Never Use the Hodrick-Prescott Filter: https://www.nber.org/papers/w23429 Robert Hodrick, exploration of trend-cycle decomposition methods: https://www.nber.org/papers/w26750

Previous: Hobbs algorithm Next: Hoeffding's independence test

  • Home
  • Daily AI Updates
  • Blog
  • AIFBL Academy
  • AI Glossary
  • Products and Tools
  • Store
  • Free CFO AI Prompt Pack
  • About Shihan Sheriff
  • Privacy Policy
  • Terms of Use
  • Refund Policy
  • Cookie Policy
  • Earnings Disclaimer