hamilton_filter: Time Series Filtering Using the Hamilton Filter
Description
A stationary remainder is obtained from a univariate time series using the
filter proposed by Hamilton. The filter is capable of estimating the trend
together with the seasonality in a series.
Usage
hamilton_filter(yt, h = NULL, p = NULL)
Value
A list with the following elements is returned.
decomp
an object of class "mts" that consists of the
decomposed time series data.
ts_name
the object name of the initially provided time series object.
frequency
the frequency of the time series.
regression_output
an object of class "lm", i.e. basic regression
output.
Arguments
yt
a time series object of class ts or an object that can be
transformed to that class using as.ts.
h
the backwards time skip for the first regressor; the default is
the seasonal period in yt multiplied by 2.
p
the number of regressors; the default is the seasonal period in
yt.
Details
Implement the filter by Hamilton (2018) to decompose a time series.
References
Hamilton, J. D. (2018). Why You Should Never Use the Hodrick-Prescott Filter.
The Review of Economics and Statistics, 100(5): 831–843.
DOI: 10.1162/rest_a_00706.