Read Cochrane’s (1994) paper Permanent and Transitory Components of GDP and Stock Prices http://faculty.chicagobooth.edu/john.cochrane/research/papers/Cochrane%20Perm%20and%20Trans%20GNP%20and%20stocks%20(QJE).pdf.
vars
and tsDyn
and load these packages. Also, download quarterly GDP and consumption (available in 5206.0 table 2), put the two series in a spreadsheet by themselves and load the data into R.newdata <- log(olddata)
.newnewdata <- newdata %>% mutate(d.GDP = c(NA, diff(GDP)), d.CONS = c(NA, diff(CONS))) %>% filter(!is.na(d.GDP)) %>% dplyr::select(-GDP, -CONS)
.VAR(newnewdata, p = somenumberoflags, type = "const")
. You will have to choose a number of lags to include. After fitting the model, use aic(myfittedmodel)
which returns the Akaike Information Criterion—a lower number is better. How many lags should you include?myirfs <- irf(myfittedmodel)
. Plot these with plot(myirfs)
. Interpret the plots.vecm1 <- VECM(data= cg2, lag = somenumberoflags, r = 1, include = "const", estim = "ML", beta = 0)
(note that you should use the log levels, not the differences as before). Generate irfs again. Is there any substantial difference?predict(myfittedmodel, n.ahead = 4)
. You can plot these predictions.