| BoostedHP | R Documentation |
All in one function of conducting the boosted HP-filter.
BoostedHP( x, lambda = 1600, iter = TRUE, stopping = "BIC", sig_p = 0.05, Max_Iter = 100 )
x |
is a raw time series to be filtered. |
lambda |
the turning parameter, default value is 1600, as recommended by Hodrick and Prescott (1997) for quarterly data. |
iter |
logical, |
stopping |
stopping criterion. |
sig_p |
a threshold of the p-value for the ADF test, with default value 0.050.
Only effective when |
Max_Iter |
maximal number of iterations. The default is 100. |
This is the main function of implementing the boosted HP filter (Phillisp and
Shi, 2021). The arguments accommendate the orginal HP filter (iter =
FALSE), the boosted HP filter with the BIC stopping criterion (stopping =
"BIC"),
or ADF test stopping criterion
(stopping = "adf"), or keep going until the maximum number of iterations is reached
(stopping = "nonstop").
Either the original HP filter or the bHP filter requires lambda to
control the strength of the weak learner for in-sample fitting. The default
is lambda = 1600, which is recommended by Hodrick and Prescott (1997)
for quarterly data. lambda should be adjusted for different
frequencies. For example, lambda = 129600 for monthly data and
lambda = 6.25 for annual data.
See the vignette with a brief introduction of the idea of bHP.
The function returns a list containing the following items:
cycle |
The cyclical component in the final iteration. |
trend |
The trend component in the final iteration. |
trend_hist |
The estimated trend in each iteration. |
iter_num |
The total number of iterations when it stops. |
IC_hist |
The path of the BIC up to the final iterations. |
adf_p_hist |
The path of the ADF test p-value up to the final iteration. |
Peter Phillips and Zhentao Shi, 2021: "Boosting: Why You Can Use the HP Filter," International Economic Review, 62(2), 521-570
data(IRE) # load the data 'IRE' lam <- 100 # tuning parameter for the annual data # raw HP filter bx_HP <- BoostedHP(IRE, lambda = lam, iter= FALSE) # by BIC bx_BIC <- BoostedHP(IRE, lambda = lam, iter= TRUE, stopping = "BIC") # by ADF bx_ADF <- BoostedHP(IRE, lambda = lam, iter= TRUE, stopping = "adf") # If stopping = "nonstop", # Iterated HP filter until Max_Iter and keep the path of BIC. bx_nonstop <- BoostedHP(IRE, lambda = lam, iter= TRUE, stopping = "nonstop")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.