View source: R/fitting_functions.R
hamilton_filter | R Documentation |
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.
hamilton_filter(yt, h = NULL, p = NULL)
yt |
a time series object of class |
h |
the backwards time skip for the first regressor; the default is
the seasonal period in |
p |
the number of regressors; the default is the seasonal period in
|
Implement the filter by Hamilton (2018) to decompose a time series.
A list with the following elements is returned.
an object of class "mts"
that consists of the
decomposed time series data.
the object name of the initially provided time series object.
the frequency of the time series.
an object of class "lm"
, i.e. basic regression
output.
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.
est <- hamilton_filter(log(EXPENDITURES))
est
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.