Package: mhpfilter 1.0.0

mhpfilter: Modified and Fully Modified Hodrick-Prescott Filters

Decomposes macroeconomic time series into trend and cycle with the Hodrick-Prescott (HP) filter and two data-driven versions of it. The modified HP filter of McDermott (1997), assessed by Choudhary, Hanif and Iqbal (2014) <doi:10.1080/00036846.2014.894631>, chooses the smoothing parameter of every series by generalised cross-validation (as described in Coe and McDermott (1997) <doi:10.2307/3867497>). The fully modified HP filter of Hanif, Iqbal and Choudhary (2017, State Bank of Pakistan Working Paper 88) also reduces the end-point bias of the HP filter: it raises the smoothing parameter at the first and last observations, with linear or quadratic weights chosen to minimise the loss of Bloechl (2014, University of Munich Discussion Paper 2014-1). Every filter is a banded linear solve, so the searches are fast; batch processing of many series, comparisons of the filters, the filter weights, gain functions and end-point loss, simulation of trend-plus-cycle series and the power comparison of the paper, 'ggplot2' graphics, a plain-language interpretation of every result and a built-in 'shiny' application.

Authors:Muhammad Yaseen [aut, cre, cph], Javed Iqbal [ctb], M. Nadim Hanif [ctb, cph], M. Ali Choudhary [ctb]

mhpfilter_1.0.0.tar.gz
mhpfilter_1.0.0.zip(r-4.7-x86_64)mhpfilter_1.0.0.zip(r-4.7-arm64)mhpfilter_1.0.0.zip(r-4.6-x86_64)mhpfilter_1.0.0.zip(r-4.6-arm64)mhpfilter_1.0.0.zip(r-4.5-x86_64)
mhpfilter_1.0.0.tgz(r-4.6-x86_64)mhpfilter_1.0.0.tgz(r-4.6-arm64)mhpfilter_1.0.0.tgz(r-4.5-x86_64)mhpfilter_1.0.0.tgz(r-4.5-arm64)
mhpfilter_1.0.0.tar.gz(r-4.7-arm64)mhpfilter_1.0.0.tar.gz(r-4.7-x86_64)mhpfilter_1.0.0.tar.gz(r-4.6-arm64)mhpfilter_1.0.0.tar.gz(r-4.6-x86_64)
mhpfilter_1.0.0.tgz(r-4.6-emscripten)
manual.pdf |manual.html✨
DESCRIPTION |NEWS
card.svg |card.png
mhpfilter/json (API)

# Install 'mhpfilter' in R:
install.packages('mhpfilter', repos = c('https://myaseen208.r-universe.dev', 'https://cloud.r-project.org'))

Bug tracker:https://github.com/myaseen208/mhpfilter/issues

Pkgdown/docs site:https://myaseen208.com

Uses libs:
  • c++– GNU Standard C++ Library v3
  • openmp– GCC OpenMP (GOMP) support library
Datasets:
  • us_macro - United States real GDP, consumption and investment, 1959 to 2009

On CRAN:

Conda:

quartocppopenmp

5.62 score 2 stars 211 downloads 27 exports 20 dependencies

Last updated from:c3b04c2257. Checks:15 OK. Indexed: yes.

TargetResultTimeFilesSyslog
linux-devel-arm64OK168
linux-devel-x86_64OK175
source / vignettesOK284
linux-release-arm64OK165
linux-release-x86_64OK174
macos-release-arm64OK219
macos-release-x86_64OK271
macos-oldrel-arm64OK210
macos-oldrel-x86_64OK357
windows-devel-arm64OK475
windows-devel-x86_64OK245
windows-release-arm64OK452
windows-release-x86_64OK209
windows-oldrel-x86_64OK196
wasm-releaseOK100

Exports:batch_comparefmhp_batchfmhp_comparefmhp_filterfmhp_simulationget_gcvget_lambdahp_filterhp_gainhp_losshp_schedulehp_weightsmhp_appmhp_app_objectmhp_batchmhp_citemhp_comparemhp_designsmhp_filtermhp_interpretmhp_notationmhp_referencemhp_savemhp_simulatemhp_themeplot_batchplot_comparison

Dependencies:clicpp11data.tablefarverggplot2gluegtableisobandlabelinglifecycleR6RColorBrewerRcppRcppArmadillorlangS7scalesvctrsviridisLitewithr

Getting started with mhpfilter
Abstract | The data | Three filters | The HP filter | The modified HP filter | The fully modified HP filter | Comparing the filters | Many series | Reading the results | Where next | References

Last update: 2026-11-06
Started: 2026-11-06

Getting started with mhpfilter (PDF)
Abstract | The data | Three filters | Comparing the filters | Many series | Reading the results | Where next | References

Last update: 2026-11-06
Started: 2026-11-06

Reproducing the fully modified HP filter
Abstract | The published values | Weights (Figures 1 and 1a) | Gains (Figures 2 and 2b) | Loss (Figures 3 and 3b; Tables 3a and 3b) | The filter on US data | Agreement with the MATLAB code | References

Last update: 2026-11-06
Started: 2026-11-06

Reproducing the fully modified HP filter (PDF)
Abstract | The published values | Weights (Figures 1 and 1a) | Gains (Figures 2 and 2b) | Loss (Figures 3 and 3b; Tables 3a and 3b) | The filter on US data | Agreement with the MATLAB code | References

Last update: 2026-11-06
Started: 2026-11-06

Simulation study
Abstract | The design | Results | Reading the results | References

Last update: 2026-11-06
Started: 2026-11-06

Simulation study (PDF)
Abstract | The design | Results | Reading the results | References

Last update: 2026-11-06
Started: 2026-11-06

The application
Abstract | Starting the application | The pages | Reproducibility | Deploying | References

Last update: 2026-11-06
Started: 2026-11-06

The application (PDF)
Abstract | Starting the application | The pages | Reproducibility | Deploying | References

Last update: 2026-11-06
Started: 2026-11-06

The filters: theory and computation
Abstract | The HP filter | Choosing lambda from the data | The criterion of the modified HP filter | The two criteria on the US data | The end-point bias | Weights | Gains | Loss | The fully modified HP filter | End-point schemes | Two forms of the weights | The procedure | References

Last update: 2026-11-06
Started: 2026-11-06

The filters: theory and computation (PDF)
Abstract | The HP filter | Choosing lambda from the data | The end-point bias | The fully modified HP filter | References

Last update: 2026-11-06
Started: 2026-11-06

The modified HP filter
Abstract | The idea | One series | Three US series | Against the HP filter | How stable is the choice? | The simulation designs of the paper | References

Last update: 2026-11-06
Started: 2026-11-06

The modified HP filter (PDF)
Abstract | The idea | One series | Three US series | Against the HP filter | How stable is the choice? | The simulation designs of the paper | References

Last update: 2026-11-06
Started: 2026-11-06

Validation and speed
Abstract | Against version 0.1.0 | Against dense computations | Against the MATLAB code | Against the published values | Speed | References

Last update: 2026-11-06
Started: 2026-11-06

Validation and speed (PDF)
Abstract | Against version 0.1.0 | Against dense computations | Against the MATLAB code | Against the published values | Speed | References

Last update: 2026-11-06
Started: 2026-11-06

Readme and manuals

Help Manual

Help pageTopics
Plot the decomposition of a seriesautoplot.mhp
Fully modified HP filter of many seriesfmhp_batch fmhp_batch.default
Compare the HP, modified HP and fully modified HP filtersfmhp_compare fmhp_compare.default
Fully modified Hodrick-Prescott filterfmhp_filter fmhp_filter.default
Power comparison of the filters on simulated seriesfmhp_simulation
Extract the smoothing parameter or the criterion of a resultget_gcv get_gcv.default get_lambda get_lambda.default
Hodrick-Prescott filter with a fixed smoothing parameterhp_filter hp_filter.default
Gain functions of an HP-type filterhp_gain hp_gain.default
End-point loss of an HP-type filterhp_loss hp_loss.default
Smoothing parameters with raised end valueshp_schedule
Weights of an HP-type filterhp_weights hp_weights.default
Trend and cycle analysis in a web browsermhp_app mhp_app_object
Modified HP filter of many seriesmhp_batch mhp_batch.default
References of a result or of the packagemhp_cite mhp_cite.default
Compare the HP and the modified HP filterbatch_compare batch_compare.default mhp_compare mhp_compare.default
The 30 simulation designs of Hanif, Iqbal and Choudhary (2017)mhp_designs
Modified Hodrick-Prescott filter: the smoothing parameter chosen from the datamhp_filter mhp_filter.default
Plain-language interpretation of a resultformat.mhp_interpretation mhp_interpret mhp_interpret.default print.mhp_interpretation
Notation of mhpfiltermhp_notation
Published values used by the tests and vignettesmhp_reference
Save a figure (vector PDF by default)mhp_save mhp_save.default
Simulate a series with a known trend and cyclemhp_simulate
ggplot2 theme of mhpfiltermhp_theme
Methods for mhpfilter resultsas.data.frame.mhp_result as.data.table.mhp_result format.mhp_result mhp-methods plot.mhp_result print.mhp_result print.summary.mhp_result summary.mhp_result
Plot the results of many seriesplot_batch
Plot the HP and modified HP filters of one seriesplot_comparison
Print a filter resultprint.mhp
United States real GDP, consumption and investment, 1959 to 2009 (quarterly)us_macro