knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "README-"
)

Installation

library(devtools)
install_github("ChandlerLutz/VARfunctions")
library(VARfunctions)

Load example Data

Load the data directly from the package

data(us.macro.data)
#Industrial Production, CPI less food and energy,
#and the Fed funds rate downloaded from the FRED
#(see below for how the data was downloaed)
head(us.macro.data)

The data is an xts object

is.xts(us.macro.data)

Local Projection Impulse Response

The lp_irf() function returns the local projection impulse response of Jorda (2005) for forecast horizon h and max.lags max lags

lp_irf(us.macro.data, h = 1, max.lags = 14)

The functions returns the IRFs for each variable following a reduced form disturbance in every other variable. Reading the bottom row for FEDFUNDS.1, we can see that a 1 unit (1 percentage point increase) in the fed funds rate is associated with a 0.016 percent increase in industrial production, a 0.025 percent increase in the inflation rate, a -0.0077 percentage point decline in the unemployment rate, and a 1.3 percentage point increase in the fed funds rate the next month.

Local Projection Impulse Response h = 1,...,12

LP.irfs.out <- lapply(1:12, function(h) {
    lp_irf(y = us.macro.data, h = h,
           max.lags = 14)
})
LP.irfs.out <- do.call("rbind", LP.irfs.out)
head(LP.irfs.out)

Local Projection IRFs for just the fed funds rate

LP.irfs.out[grepl("FEDFUNDS", rownames(LP.irfs.out)), ]

How the data was downloaded

The following code shows how to download the package data

#Load packages
library(quantmod)
#Time Series that we want to download
#Note: ORDER MATTERS for structural identification
#Industrial Production, CPI less food and energy,
#and the Fed funds rate
ts <- c("INDPRO", "CPILFESL", "UNRATE", "FEDFUNDS")
getSymbols(ts, src="FRED")
#Log first difference of industrial production
INDPRO <- na.omit(diff(log(INDPRO)) * 100)
#Log first difference of CPI
CPILFESL <- na.omit(diff(log(CPILFESL)) * 100)
#Merge all of the time series
us.macro.data <- INDPRO
for (i in 2:length(ts))
    us.macro.data <- na.omit(merge(us.macro.data, get(ts[i])))
us.macro.data <- us.macro.data["/2008-01-01"] ##Up to 2008-01-01


ChandlerLutz/VARfunctions documentation built on May 6, 2019, 9:56 a.m.