The R package neverhpfilter recreates the econometric methods proposed in "Why You Should Never Use the Hodrick-Prescott Filter" by James Hamilton (2017).
The package is available on CRAN and on GitHub.
See the Getting Started vignette and the Recreating Hamlton vignette.
A comprehensive vignette recreating the original working paper is found at Reproducing Hamilton on Justin M. Shea's homepage.
Also check out the R package boosted_hp_filter that recreates teh econometric methods proposed in "Boosting: Why You Can Use the HP Filter" by Peter Phillips and Zhentao Shi (2021).
The package is available on GitHub and described online.
Note that the R package Boosted_HP_filter is superseded and has been replaced by R package BoostedHP.
The package vignette is available on GitHub.
Shea J (2021). neverhpfilter: An Alternative to the Hodrick-Prescott Filter. R package version 0.4-0, https://CRAN.R-project.org/package=neverhpfilter.
Peter Phillips and Zhentao Shi, "Boosting: Why You Can Use the HP Filter," International Economic Review, 62(2), 521-570, https://onlinelibrary.wiley.com/doi/10.1111/iere.12495.