Today

Multivariate Forecasts

Multivariate Forecasting Setup

Multivariate Forecasting Goals

Forecasting Rules for Multivariate Forecasts

Vector Autoregression

Implementation and Example: GDP Forecasting Revisited

#Libraries
library(fpp2) #Forecasting and Plotting tools
library(vars) #Vector Autoregressions
library(fredr) #Access FRED Data
library(knitr) #Use knitr to make tables
library(kableExtra) #Extra options for tables

##Obtain and transform NIPA Data (cf Lecture 08)

fredr_set_key("8782f247febb41f291821950cf9118b6") #Key I obtained for this class

#US GDP components 
GDP<-fredr(series_id = "GDP",
           observation_start = as.Date("1947-01-01"),
           observation_end=as.Date("2019-02-12")) #Gross Domestic Product

#US GDP components from NIPA tables (cf http://www.bea.gov/national/pdf/nipaguid.pdf)
PCEC<-fredr(series_id = "PCEC",
            observation_start = as.Date("1947-01-01"),
            observation_end=as.Date("2019-02-12")) #Personal consumption expenditures
FPI<-fredr(series_id = "FPI",
           observation_start = as.Date("1947-01-01"),
           observation_end=as.Date("2019-02-12")) #Fixed Private Investment
CBI<-fredr(series_id = "CBI",
           observation_start = as.Date("1947-01-01"),
           observation_end=as.Date("2019-02-12")) #Change in Private Inventories
NETEXP<-fredr(series_id = "NETEXP",
              observation_start = as.Date("1947-01-01"),
              observation_end=as.Date("2019-02-12")) #Net Exports of Goods and Services
GCE<-fredr(series_id = "GCE",
           observation_start = as.Date("1947-01-01"),
           observation_end=as.Date("2019-02-12")) #Government Consumption Expenditures and Gross Investment

#Format the series as quarterly time series objects, starting at the first date
gdp<-ts(GDP$value,frequency = 4,start=c(1947,1),names="Gross Domestic Product") 
pcec<-ts(PCEC$value,frequency = 4,start=c(1947,1),names="Consumption")
fpi<-ts(FPI$value,frequency = 4,start=c(1947,1),names="Fixed Investment")
cbi<-ts(CBI$value,frequency = 4,start=c(1947,1),names="Inventory Growth")
invest<-fpi+cbi #Private Investment
netexp<-ts(NETEXP$value,frequency = 4,start=c(1947,1),names="Net Exports")
gce<-ts(GCE$value,frequency = 4,start=c(1947,1),names="Government Spending")

#Convert to log differences to ensure stationarity and collect in frame
NIPAdata<-ts(data.frame(diff(log(gdp)),diff(log(pcec)),diff(log(invest)),diff(log(gce))),frequency = 4,start=c(1947,1),end=c(2018,3))
NIPAVAR<-VAR(NIPAdata,p=1) #VAR(1) in Y=log.diff.gdp, C=log.diff.pcec, I=log.diff.invest, G=log.diff.gce
NIPAfcst<-forecast(NIPAVAR) #Produce forecasts of all series
Estimated VAR Coefficients
GDP Consumption Investment Government
Lagged Change log Y 0.1202982 0.4384795 -1.9641401 0.1247220
Lagged Change log C 0.4084516 -0.1129436 3.5886042 0.0105691
Lagged Change log I 0.0356386 -0.0036534 0.3597251 0.0438564
Lagged Change log G 0.0095231 -0.0499654 -0.3891585 0.5990209
Constant 0.0065023 0.0114936 -0.0093123 0.0035254

Forecast Results

autoplot(NIPAfcst)+
  labs(title = "VAR(1) Forecasts of GDP and and NIPA Component Growth")

Multi-period Forecasts

Alternate Approaches

Recursive Substitution for Multi-period Forecasts

Example: Extending an AR(2) Forecast

More Applications of Recursive Substitution

Economic Motivation for VAR models

Classical Statistics Perspective

Evaluating Autoregressive Forecasts

Application to GDP Series in VAR(1) Example

checkresiduals(NIPAVAR$varresult$diff.log.gdp..) #GDP Growth forecast residual diagnostic

## 
##  Breusch-Godfrey test for serial correlation of order up to 10
## 
## data:  Residuals
## LM test = 35.798, df = 10, p-value = 9.119e-05

Summary

Caveats

References