auto_hpfjx | R Documentation |
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.
The regularization constant for the HP filter with jumps is the
maximal sum of standard deviations for the level disturbance. This value
has to be passed to the hpfjx
function. The auto_hpfjx
runs
hpfjx
on a grid of regularization constants and returns the output
of hpfjx
selected by the chosen information criterion.
auto_hpfjx(
y,
X,
grid = seq(0, sd(y) * 10, sd(y)/10),
ic = c("bic", "hq", "aic", "aicc"),
edf = TRUE
)
y |
numeric vector cotaining the time series; |
X |
numeric matrix with regressors in the columns; |
grid |
numeric vector containing the grid for the argument |
ic |
string with information criterion for the choice: the default is "bic" (simulations show this is the best choice), but also "hq", "aic" and "aicc" are available; |
edf |
logical scalar: TRUE (default) if the number of degrees of freedom should be computed as "effective degrees of freedom" (Efron, 1986) as opposed to a more traditional way (although not supported by theory) when FALSE. |
The ouput of the hpjf
function corresponding to the best
choice according to the selected information criterion.
y <- log(AirPassengers)
n <- length(y)
mod <- auto_hpfjx(y, trigseas(n, 12))
hpj <- ts(mod$smoothed_level, start(y), frequency = 12)
plot(y)
lines(hpj, col = "red")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.