HPFilter.jl is a Julia module that implements the Hodrick-Prescott (HP) filter as well as the its generalization generally known as Whittaker-Henderson smoothing, in this package named bohl_filter after its first inventor George Bohlmann.
In addition this module tries to implement also more novel approaches, so far the boosted HP Filter based on Peter Phillips and Zhentao Shi (2019): "Boosting the Hodrick-Prescott Filter" has been implemented.
This module can either be employed by cloning this repository or by using the Julia package manager. With the package manager simply use the add command:
(v1.11) pkg> add https://github.com/sdBrinkmann/HPFilter.jl
The basic usage is demonstrated with the US industrial production index (IPI) provided by FRED data service.
using HPFilter
using CSV
# Set path to directory where time series is located
path = "/.../data"
IPI = CSV.read("$(path)/IPB50001SQ.csv", copycols=true)
# HP filter with λ = 1600
hp = HP(IPI[!, 2], 1600)
# The above is equivalent to Whittaker-Henderson smoothing with m = 2 differentation
wh = bohl_filter(IPI[!, 2], 2, 1600)
# Boosted HP filter with baysian-type information criterion (BIC)
bHP_bic = bHP(IPI[!, 2], 1600, Criterion="BIC")
# Boosted HP filter with augmented Dickey-Fuller (ADF) test
bHP_adf = bHP(IPI[!, 2], 1600, Criterion="ADF", p=0.01)