BoostedHP: Boosting the Hodrick-Prescott Filter

View source: R/BoostedHP.R

BoostedHPR Documentation

Boosting the Hodrick-Prescott Filter

Description

All in one function of conducting the boosted HP-filter.

Usage

BoostedHP(
  x,
  lambda = 1600,
  iter = TRUE,
  stopping = "BIC",
  sig_p = 0.05,
  Max_Iter = 100
)

Arguments

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, TRUE (default) to conduct the boosted HP filter. FALSE does not iterated, which is exactly the original HP filter.

stopping

stopping criterion. "BIC" (default), or "adf", or "nonstop" means keeping iteration until the maximum number of iteration, specified by Max_Iter is reached.

sig_p

a threshold of the p-value for the ADF test, with default value 0.050. Only effective when stopping = "adf".

Max_Iter

maximal number of iterations. The default is 100.

Details

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.

Value

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.

References

Peter Phillips and Zhentao Shi, 2021: "Boosting: Why You Can Use the HP Filter," International Economic Review, 62(2), 521-570

Examples


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")

chenyang45/BoostedHP documentation built on Nov. 12, 2022, 11:36 a.m.