README.md

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)
#>                INDPRO  CPILFESL UNRATE FEDFUNDS
#> 1957-02-01  0.9745162 0.3502631    3.9     3.00
#> 1957-03-01 -0.1215136 0.3490405    3.7     2.96
#> 1957-04-01 -1.3438454 0.3478264    3.9     3.00
#> 1957-05-01 -0.3699405 0.0000000    4.1     3.00
#> 1957-06-01  0.2466321 0.3466208    4.3     3.00
#> 1957-07-01  0.6141511 0.3454235    4.2     2.99

The data is an xts object

is.xts(us.macro.data)
#> [1] TRUE

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)
#>                 INDPRO    CPILFESL       UNRATE    FEDFUNDS
#> INDPRO.1    0.21171391  0.01301449 -0.070674763  0.05570750
#> CPILFESL.1 -0.18674398  0.08414340  0.127010120  0.05930266
#> UNRATE.1   -0.56634206 -0.04103560  0.752356608 -0.59786410
#> FEDFUNDS.1  0.01619017  0.02575645 -0.007780288  1.29636912

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)
#>                 INDPRO     CPILFESL       UNRATE    FEDFUNDS
#> INDPRO.1    0.21171391  0.013014485 -0.070674763  0.05570750
#> CPILFESL.1 -0.18674398  0.084143398  0.127010120  0.05930266
#> UNRATE.1   -0.56634206 -0.041035603  0.752356608 -0.59786410
#> FEDFUNDS.1  0.01619017  0.025756450 -0.007780288  1.29636912
#> INDPRO.2    0.09889848 -0.002320366 -0.103059282  0.17507927
#> CPILFESL.2 -0.14596619  0.181077443  0.183870574 -0.05858644

Local Projection IRFs for just the fed funds rate

LP.irfs.out[grepl("FEDFUNDS", rownames(LP.irfs.out)), ]
#>                   INDPRO    CPILFESL        UNRATE  FEDFUNDS
#> FEDFUNDS.1   0.016190174 0.025756450 -0.0077802881 1.2963691
#> FEDFUNDS.2   0.096428234 0.094136275 -0.0007051016 1.1916686
#> FEDFUNDS.3   0.044522390 0.059676727 -0.0261084992 1.0840282
#> FEDFUNDS.4  -0.015708028 0.039438675 -0.0289441105 0.9569509
#> FEDFUNDS.5  -0.147674094 0.004586079  0.0032999408 0.8856035
#> FEDFUNDS.6  -0.129401514 0.038199757  0.0026441211 0.8603805
#> FEDFUNDS.7  -0.110640562 0.011161172  0.0465090293 0.5515423
#> FEDFUNDS.8  -0.130037756 0.053590646  0.0200207452 0.6528141
#> FEDFUNDS.9   0.001330222 0.042404521  0.0292551559 0.7868326
#> FEDFUNDS.10 -0.079854489 0.033012060  0.0533419033 0.8747683
#> FEDFUNDS.11 -0.081961798 0.027728200  0.1311552802 0.7169403
#> FEDFUNDS.12 -0.130842969 0.038943212  0.1400608419 0.5900689

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.