# hpconf: Confidence Bands for the Hodrick-Prescott Filter In franzmohr/hpconf: Confidence Bands for the Hodrick-Prescott Filter

## Description

A function for the calculation of confidence bands for the trend component of the Hodrick-Prescott (HP) filter as proposed by Giles (2013).

## Usage

 1 hpconf(data, V_y = NULL, ci = 0.95) 

## Arguments

 data an object of class "mFilter" containing the output of the function hpfilter. V_y a numeric specifying the variance of the cyclical component. If V_y = NULL (default), the sample variance of the original time series will be used. ci numeric between 0 and 1 specifying the confidence interval. Defaults to 0.95.

## Details

The function uses the filter matrix F from an "mFilter" object to obtain the matrix Q = ≤ft[I_T + λ K' K]^{-1}\right]. Since Q y provides an estimate of the trend \hat{tau} and F y yields the cyclical component of the process \hat{c} and the time series y is decomposed only into those two components so that y = \hat{tau} + \hat{c}, Q can be obtained from I_T y - Fy = Q y so that Q = I_T - F.

The confidence band is then derived from the covariance matrix V(\hat{tau}) = Q V(y) Q.

By default V_y = NULL so that the sample variance of the original time series is used for the construction of V(y). This can be chanced by providing a numeric value, for example from the output of an esitmated ARIMA model.

## Value

A time-series object of four variables

• trend: The estimated trend component

• ci_lower: The lower bound of the confidence band

• ci_upper: The upper bound of the confidence band

• y: The actual series

## References

Giles, D. E. (2013). Constructing confidence bands for the Hodrick-Prescott filter. Applied Economics Letters, 20(5), 480–484. https://doi.org/10.1080/13504851.2012.714057

## Examples

  1 2 3 4 5 6 7 8 9 10 11 12 13 14 library(mFilter) library(hpconf) # Load data data("unemp") # Run HP-filter hp_unemp <- hpfilter(unemp) # Obtain confidence bands hp_conf <- hpconf(hp_unemp) # Plot plot(hp_conf) 

franzmohr/hpconf documentation built on Nov. 5, 2021, 10:17 p.m.