knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
The goal of tsfilters is to provide various time series filters.
You can install the released version of tsfilters from GitHub with:
# install.packages("devtools") devtools::install_github("saviviro/tsfilters")
Separate trend and cyclical component of univariate time series using the method proposed by Hamilton (2018, doi:10.1162/rest_a_00706).
library(tsfilters) data(INDPRO, package="tsfilters") ## Hamilton (2018) filter: IP_filtered <- hfilter(log(INDPRO), h=24, p=12) IP_filtered plot(IP_filtered) ## The first difference of logarithmized series: IP_logdiff <- logdiff(INDPRO) plot(IP_logdiff) ## HP filter: # Log of quarterly industrial production index IPQ <- log(colMeans(matrix(INDPRO, nrow=3))) IPQ <- ts(IPQ, start=start(INDPRO), frequency=4) # One-sided IPQ_hp <- hpfilter(IPQ, lambda=1600, type="one-sided") plot(IPQ_hp) IPQ_hp # Two-sided IPQ_hp2 <- hpfilter(IPQ, lambda=1600, type="two-sided") plot(IPQ_hp2) IPQ_hp2
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.