Learn R Programming

Hodrick-Prescott filter with automatically selected jumps

This R package implements our novel method to supplement the classical HP filter with jumps and, possibly, regressors. The method is based on the following state-space representation

$$y_t = x_t^\top \beta + \mu_t + \varepsilon_t$$

$$\mu_{t+1} = \mu_t + \nu_t$$

$$\nu_{t+1} = \nu_t + \zeta_t,$$

where $y_t$ is the observable time series, $\mu_t$ is the level component, $\nu_t$ is the slope component, $\varepsilon_t$ and $\zeta_t$ are white noise sequences with variances $\sigma^2_\varepsilon$ and $\sigma^2_\zeta$, respectively. The smoother, that is, the linear projection of $\mu_t$ on the span of the observations ${y_1,\ldots,y_n}$, coincides with the HP filter, where the smoothing constant $\lambda$ is given by $\sigma^2_\varepsilon / \sigma^2_\zeta$. Finally, $x_t$ is a vector of regressors, and $\beta$ is a vector of regression coefficients. These regressors are mainly used to model seasonal patterns in the data and should have a zero mean to not alter the interpretation of the HP filter as a trend extractor.

Copy Link

Version

Install

install.packages('jumps')

Monthly Downloads

207

Version

1.0

License

GPL-3

Maintainer

Matteo Pelagatti

Last Published

March 24th, 2025

Functions in jumps (1.0)

hpj

Hodrick-Prescott filter with jumps
llt

Kalman filtering and smoothing for local linear trend plus noise
trigseas

Trigonometric seasonal variables
plot.hpj

Plot method for the class hpj
print.hpj

Print method for the class hpj
da

Internal function for computing scores w/r to regression coefficients
dummyseas

Seasonal dummy variables
hpfj_fix

HP filter with automatic jumps detection and fixed smoothing constant
auto_hpfjx

Automatic selection of the optimal HP filter with jumps and regressors
hpfj

HP filter with automatic jumps detection.
employed_IT

Dataset: employed_IT
hpfjx

HP filter with jumps and regressors (still experimental)
auto_hpfj_fix

Automatic selection of the optimal HP filter with jumps and fixed smoothing constant
auto_hpfj

Automatic selection of the optimal HP filter with jumps
BIC.hpj

BIC method for the class hpj
logLik.hpj

logLik method for the class hpj
mse

Mean squared error
jumps-package

Hodrick-Prescott Filter with Jumps
nobs.hpj

nobs method for the class hpj