hpfjx: HP filter with jumps and regressors (still experimental)

View source: R/hpfjx.R

hpfjxR Documentation

HP filter with jumps and regressors (still experimental)

Description

This function needs more testing since it does not seem to work as expected. For this reasin the wrapper hpj at the moment does not allow regressors. This is the same as hpfj but with the possibility of including regressors. The regressors should be zero-mean so that the HP filter can be interpreted as a mean value of the time series. Jumps happen contextually in the level and in the slope: the standard deviation of the slope disturbance is \gamma times the standard deviation of the level disturbance at time t. The HP smoothing parameter \lambda is estimated via MLE (assuming normally distributed disturbances) as in Wahba (1978): \lambda = \sigma^2_\varepsilon / \sigma^2_\zeta.

Usage

hpfjx(y, X, maxsum = sd(y), edf = TRUE, parinit = NULL)

Arguments

y

vector with the time series

X

matrix with regressors in the columns

maxsum

maximum sum of additional level standard deviations;

edf

boolean if TRUE computes effective degrees of freedom otherwise computes the number of degrees of freedom in the LASSO-regression way.

parinit

either NULL or vector of 3+n parameters with starting values for the optimizer; the order of the parameters is sd(slope disturbnce), sd(observatio noise), square root of gamma, n additional std deviations for the slope

Value

list with the following slots:

  • opt: the output of the optimization function (nloptr)

  • nobs: number of observations

  • df: number of estimated parameters (model's degrees of freedom)

  • loglik: value of the log-likelihood at maximum

  • ic: vector of information criteria (aic, aicc, bic, hq)

  • smoothed_level: vector with smoothed level with jumps (hp filter with jumps)

  • var_smoothed_level: variance of the smoothed level

References

Whaba (1978) "Improper priors, spline smoothing and the problem of guarding against model errors in regression", *Journal of the Royal Statistical Society. Series B*, Vol. 40(3), pp. 364-372. DOI:10.1111/j.2517-6161.1978.tb01050.x

Examples

y <- log(AirPassengers)
n <- length(y)
mod <- hpfjx(y, trigseas(n, 12))
hpj <- ts(mod$smoothed_level, start(y), frequency = 12)
plot(y)
lines(hpj, col = "red")


jumps documentation built on April 4, 2025, 2:22 a.m.