mhpfilter: Modified Hodrick-Prescott Filter with Optimal Smoothing Parameter Selection

High-performance implementation of the Modified Hodrick-Prescott (HP) Filter for decomposing macroeconomic time series into trend and cyclical components. Based on the methodology of Choudhary, Hanif and Iqbal (2014) <doi:10.1080/00036846.2014.894631> "On smoothing macroeconomic time series using the modified HP filter", which uses generalized cross-validation (GCV) to automatically select the optimal smoothing parameter lambda, following McDermott (1997) "An automatic method for choosing the smoothing parameter in the HP filter" (as described in Coe and McDermott (1997) <doi:10.2307/3867497>). Unlike the standard HP filter that uses fixed lambda values (1600 for quarterly, 100 for annual data), this package estimates series-specific lambda values that minimize the GCV criterion. Implements efficient C++ routines via 'RcppArmadillo' for fast computation, supports batch processing of multiple series, and provides comprehensive visualization tools using 'ggplot2'. Particularly useful for cross-country macroeconomic comparisons, business cycle analysis, and when the appropriate smoothing parameter is uncertain.

Version: 0.1.0
Depends: R (≥ 4.0.0)
Imports: Rcpp (≥ 1.0.0), RcppArmadillo (≥ 0.12.0.0.0), data.table (≥ 1.14.0), collapse (≥ 2.0.0), ggplot2 (≥ 3.4.0)
LinkingTo: Rcpp, RcppArmadillo
Suggests: knitr (≥ 1.40), rmarkdown (≥ 2.20), testthat (≥ 3.0.0), tidyverse (≥ 2.0.0), fastverse (≥ 0.3.0)
Published: 2026-02-13
DOI: 10.32614/CRAN.package.mhpfilter (may not be active yet)
Author: Muhammad Yaseen ORCID iD [aut, cre], Javed Iqbal [ctb] (Original methodology author), M. Nadim Hanif [ctb] (Original methodology author)
Maintainer: Muhammad Yaseen <myaseen208 at gmail.com>
BugReports: https://github.com/myaseen208/mhpfilter/issues
License: MIT + file LICENSE
URL: https://myaseen208.com/mhpfilter/
NeedsCompilation: yes
Language: en-US
Citation: mhpfilter citation info
Materials: README, NEWS
CRAN checks: mhpfilter results

Documentation:

Reference manual: mhpfilter.html , mhpfilter.pdf
Vignettes: Introduction to mhpfilter (source, R code)
Modified HP Filter: Theory and Methodology (source, R code)

Downloads:

Package source: mhpfilter_0.1.0.tar.gz
Windows binaries: r-devel: not available, r-release: not available, r-oldrel: not available
macOS binaries: r-release (arm64): mhpfilter_0.1.0.tgz, r-oldrel (arm64): mhpfilter_0.1.0.tgz, r-release (x86_64): not available, r-oldrel (x86_64): not available

Linking:

Please use the canonical form https://CRAN.R-project.org/package=mhpfilter to link to this page.