hpj | R Documentation |
This function is a wrapper for the various Hodrick-Prescott filters with jumps functions. The end user should use this: it is simpler and more flexible than the other functions.
hpj(
y,
maxsum = NULL,
lambda = NULL,
xreg = NULL,
ic = c("bic", "hq", "aic", "aicc"),
scl = 1000
)
y |
either a numeric vector or a time series object containing the time series to filter; |
maxsum |
maximum sum of additional level standard deviations,
if |
lambda |
smoothing constant of the HP filter,
if |
xreg |
matrix of regressors; |
ic |
string with information criterion for the automatic choice of |
scl |
scaling factor for the time series (default is 1000): the time series is rescaled as (y-min(y))/(max(y)-min(y))*scl. This is done since the default starting values for the optimization seem to work well in this scale); If 'scl' is set equal to the string '"original"' the time series is not rescaled. |
S3 object of class hpj with the following slots:
y: the input time series;
maxsum: the maximum sum of additional standard deviations;
lambda: the smoothing constant of the HP filter;
pars: vector of estimated parameters (sigma_slope, sigma_noise, gamma);
hpj: the time series of the HP filter with jumps;
hpj_std: the time series of the HP filter with jumps standard deviations;
std_devs: vector of additional standard deviations of the level disturbance;
breaks: vector of indices of the breaks;
xreg: matrix of regressors;
df: model's degrees of freedom;
loglik: value of the log-likelihood at maximum;
ic: vector of information criteria (aic, aicc, bic, hq);
opt: the output of the optimization function (nloptr);
call: the call to the function.
set.seed(202311)
n <- 100
mu <- 100*cos(3*pi/n*(1:n)) - ((1:n) > 50)*n - c(rep(0, 50), 1:50)*10
y <- mu + rnorm(n, sd = 20)
hp <- hpj(y, 50)
plot(hp)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.