Suggested Citation:
Mendez C. (2020). Long Run vs Short Run Decompositions in R: The HP filter vs the Hamilton filter. R Studio/RPubs. Available at https://rpubs.com/quarcs-lab/long-run-filters
This work is licensed under the Creative Commons Attribution-Share Alike 4.0 International License.
Code examples for other series
## 'getSymbols' currently uses auto.assign=TRUE by default, but will
## use auto.assign=FALSE in 0.5-0. You will still be able to use
## 'loadSymbols' to automatically load data. getOption("getSymbols.env")
## and getOption("getSymbols.auto.assign") will still be checked for
## alternate defaults.
##
## This message is shown once per session and may be disabled by setting
## options("getSymbols.warning4.0"=FALSE). See ?getSymbols for details.
## Yearly periodicity from 1960-01-01 to 2019-01-01
Create matrix of actual, trend , and cycle values
seriesName_filtered_Hamilton <- yth_filter(seriesName,
h = 2,
p = 4,
output = c("x", "trend", "cycle"))
Rename columns
Tip: Copy and paste this link another tab of your browser.
https://rstudio.cloud/project/25043
Or simply ClickHERE