yth_glm {neverhpfilter} | R Documentation |
Fits Hamilton's alternative model
Description
yth_glm
fits a generalized linear model suggested by James D. Hamilton as a better alternative to the Hodrick-Prescott Filter.
Usage
yth_glm(x, h = 8, p = 4, ...)
Arguments
x |
A univariate xts object of any zoo index class,
such as Date , yearmon , or yearqtr .
For converting objects of type timeSeries, ts, irts, fts, matrix, data.frame
or zoo to xts , please read as.xts .
|
h |
An integer , defining the lookahead period.
Defaults to h = 8 , suggested by Hamilton. The default assumes
economic data of quarterly periodicity with a lookahead period of 2 years.
This function is not limited by the default parameter, and Econometricians may
change it as required.
|
p |
An integer , indicating the number of lags. A Default of
p = 4 , suggested by Hamilton, assumes data is of quarterly periodicity.
If data is of monthly periodicity, one may choose p = 12 or aggregate
the series to quarterly periodicity and maintain the default. Econometricians
should use this parameter to accommodate the Seasonality of their data.
|
... |
all arguments passed to the function glm
|
Details
For time series of quarterly periodicity, Hamilton suggests parameters of
h = 8 and p = 4, or an AR(4)
process, additionally lagged by 8
lookahead periods. Econometricians may explore variations of h. However, p is designed to correspond with the seasonality of a given periodicity and should be matched accordingly.
yt+h=β0+β1yt+β2yt−1+β3yt−2+β4yt−3+vt+h
v^t+h=yt+h−β^0+β^1yt+β^2yt−1+β^3yt−2+β^4yt−3
Which can be rewritten as:
yt=β0+β1yt−8+β2yt−9+β3yt−10+β4yt−11+vt
v^t=yt−β^0+β^1yt−8+β^2yt−9+β^3yt−10+β^4yt−11
Value
yth_glm
returns a generalized linear model object of class glm
,
which inherits from lm
.
References
James D. Hamilton. Why You Should Never Use the Hodrick-Prescott Filter.
NBER Working Paper No. 23429, Issued in May 2017.
See Also
glm
Examples
data(GDPC1)
gdp_model <- yth_glm(GDPC1, h = 8, p = 4, family = gaussian)
summary(gdp_model)
plot(gdp_model)
[Package
neverhpfilter version 0.4-0
Index]