Part 1: Vector Autoregression

1. Install and load the library “vars” into R

library(vars)
## Loading required package: MASS
## Loading required package: strucchange
## Loading required package: zoo
## 
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
## Loading required package: sandwich
## Loading required package: urca
## Loading required package: lmtest
library(stargazer)
## 
## Please cite as:
##  Hlavac, Marek (2022). stargazer: Well-Formatted Regression and Summary Statistics Tables.
##  R package version 5.2.3. https://CRAN.R-project.org/package=stargazer

2. From the FRED-QD database we began using in PS1, use subset() to create a dataframe with the following vari-ables: INDPRO, UNRATE, GDPC1, GCEC1, PCECC96, GPDIC1, TOTALSLx, FEDFUNDS, PCECTPI, USSTHPI, GS10TB3Mx, S.P.PE.ratio.a Be sure to include them in this ordering! Remove any rows from this new dataframe which include NAs. This is a big VAR with 12 variables. With only 185 quarters worth of data we have to estimate 12 × 12 = 144 parameters in the matrix A alone! Our standard errors will be large…

fred_qd <- read.csv("fred_qd.csv")
fred_qd <- fred_qd[-(1:2),]

variables <- subset(fred_qd, select = c("INDPRO", "UNRATE", "GDPC1", "GCEC1", "PCECC96", 
                                       "GPDIC1", "TOTALSLx", "FEDFUNDS", "PCECTPI", 
                                       "USSTHPI", "GS10TB3Mx", "S.P.PE.ratio"))
variables <- na.omit(variables)

(a) Turn GDPC1, GCEC1, PCECC96, GPDIC1, and TOTALSLx into the natural log of each in this new dataframe.

variables$GDPC1 <- log(variables$GDPC1)
variables$GCEC1 <- log(variables$GCEC1)
variables$PCECC96 <- log(variables$PCECC96)
variables$GPDIC1 <- log(variables$GPDIC1)
variables$TOTALSLx <- log(variables$TOTALSLx)

3. Let’s naively forge ahead though. Estimating the VAR(1) is easy: var_out<-VAR(variables,type=”constant”), where variables is whatever you named the dataframe from question 2, and var_out can be whatever you want to name it. type=”constant” declares there should be an intercept vector as well in our model.

var_out <- VAR(variables, type = "const", p = 1)

(a) Print a nice table of results using stargazer(var_out[[“varresult”]],type=”text”), where var_out is the same as question 3. You will need to load the stargazer library first.

stargazer(var_out[["varresult"]], type = "text")
## 
## =====================================================================================================================================================================================
##                                                                                                 Dependent variable:                                                                  
##                                ------------------------------------------------------------------------------------------------------------------------------------------------------
##                                                                                                          y                                                                           
##                                    (1)         (2)         (3)           (4)           (5)          (6)           (7)         (8)          (9)           (10)       (11)      (12)   
## -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
## INDPRO.l1                        0.982***     0.015      0.0001        -0.0001       0.0002       -0.00000      -0.0003      -0.025     -0.044***     -0.471***     0.006    -0.229* 
##                                  (0.043)     (0.024)    (0.0003)      (0.0002)      (0.0003)      (0.001)      (0.0003)     (0.026)      (0.010)       (0.128)     (0.018)   (0.127) 
##                                                                                                                                                                                      
## UNRATE.l1                        0.429***   0.745***    0.002***      -0.002***     0.003***      0.008***     0.001***      -0.021       0.040*        0.038       0.051    -0.169  
##                                  (0.090)     (0.050)     (0.001)       (0.001)       (0.001)      (0.002)       (0.001)     (0.055)      (0.021)       (0.268)     (0.037)   (0.265) 
##                                                                                                                                                                                      
## GDPC1.l1                         -15.762     11.130     0.591***      -0.397***      -0.164      -1.237***     -0.693***     17.900       7.139*      -131.320**   -12.207   37.679  
##                                  (18.035)   (10.038)     (0.134)       (0.101)       (0.132)      (0.458)       (0.105)     (11.051)     (4.200)       (53.585)    (7.403)  (53.052) 
##                                                                                                                                                                                      
## GCEC1.l1                          3.705      -2.151      0.061**      1.025***       0.073**       -0.039       0.043*      -5.092**    -2.638***       0.892       2.343    -1.774  
##                                  (3.847)     (2.141)     (0.029)       (0.022)       (0.028)      (0.098)       (0.022)     (2.357)      (0.896)       (11.430)    (1.579)  (11.316) 
##                                                                                                                                                                                      
## PCECC96.l1                        6.035      -5.163      0.193*       0.287***      0.896***      1.138***     0.668***      -9.128       1.599       101.010**     9.618     3.755  
##                                  (14.805)    (8.240)     (0.110)       (0.083)       (0.108)      (0.376)       (0.086)     (9.072)      (3.448)       (43.989)    (6.077)  (43.551) 
##                                                                                                                                                                                      
## GPDIC1.l1                        8.318***   -5.371***   0.081***       0.025**      0.093***      1.126***     0.154***      -0.551       -0.168      47.638***     0.087   -12.399* 
##                                  (2.302)     (1.281)     (0.017)       (0.013)       (0.017)      (0.058)       (0.013)     (1.410)      (0.536)       (6.838)     (0.945)   (6.770) 
##                                                                                                                                                                                      
## TOTALSLx.l1                      -4.288*      2.056      -0.012        0.023*         0.001       -0.145**     0.883***      -1.724      -1.381**       -6.910      0.421     5.189  
##                                  (2.299)     (1.280)     (0.017)       (0.013)       (0.017)      (0.058)       (0.013)     (1.409)      (0.535)       (6.831)     (0.944)   (6.763) 
##                                                                                                                                                                                      
## FEDFUNDS.l1                      -0.176**    0.089**    -0.002***     0.001***      -0.002***     -0.004**      -0.0001     0.886***      0.028        -0.531**     0.042     0.046  
##                                  (0.073)     (0.041)     (0.001)      (0.0004)       (0.001)      (0.002)      (0.0004)     (0.045)      (0.017)       (0.216)     (0.030)   (0.214) 
##                                                                                                                                                                                      
## PCECTPI.l1                        0.024      -0.009      0.001*        0.0004        0.001**       0.001        -0.001       -0.040      0.948***       -0.106      0.005    -0.252  
##                                  (0.066)     (0.037)    (0.0005)      (0.0004)      (0.0005)      (0.002)      (0.0004)     (0.040)      (0.015)       (0.196)     (0.027)   (0.194) 
##                                                                                                                                                                                      
## USSTHPI.l1                        -0.002      0.001     -0.00005     -0.0001***      0.00001     -0.0002**    -0.0002***    0.007***     0.005***      0.983***   -0.004**   -0.006  
##                                  (0.004)     (0.002)    (0.00003)     (0.00002)     (0.00003)     (0.0001)     (0.00003)    (0.003)      (0.001)       (0.013)     (0.002)   (0.013) 
##                                                                                                                                                                                      
## GS10TB3Mx.l1                     -0.361**    0.170**    -0.003***       0.001       -0.002**     -0.012***      -0.001       0.006        0.004         -0.519    0.801***   -0.180  
##                                  (0.145)     (0.081)     (0.001)       (0.001)       (0.001)      (0.004)       (0.001)     (0.089)      (0.034)       (0.431)     (0.059)   (0.426) 
##                                                                                                                                                                                      
## S.P.PE.ratio.l1                  0.047***    -0.007     0.0003**       0.0001       0.0003**      0.001***     -0.0002**    -0.00001      0.001         0.088*      0.006   0.810*** 
##                                  (0.015)     (0.008)    (0.0001)      (0.0001)      (0.0001)      (0.0004)     (0.0001)     (0.009)      (0.004)       (0.045)     (0.006)   (0.045) 
##                                                                                                                                                                                      
## const                             33.116     -16.406     1.061**       0.609*        1.080**       1.844         0.031      -26.016     -43.558***      68.586      6.449   -278.103 
##                                  (57.819)   (32.180)     (0.430)       (0.324)       (0.424)      (1.469)       (0.337)     (35.428)     (13.464)     (171.788)   (23.732)  (170.079)
##                                                                                                                                                                                      
## -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
## Observations                       198         198         198           198           198          198           198         198          198           198         198       198   
## R2                                0.996       0.835       0.999         0.999         0.999        0.996         1.000       0.959        1.000         0.998       0.826     0.834  
## Adjusted R2                       0.996       0.824       0.999         0.999         0.999        0.996         1.000       0.957        1.000         0.998       0.814     0.823  
## Residual Std. Error (df = 185)    1.329       0.740       0.010         0.007         0.010        0.034         0.008       0.814        0.310         3.949       0.546     3.910  
## F Statistic (df = 12; 185)     3,999.985*** 77.862*** 25,246.390*** 17,723.740*** 30,277.540*** 3,910.969*** 84,886.210*** 364.183*** 106,258.800*** 7,286.319*** 72.950*** 77.574***
## =====================================================================================================================================================================================
## Note:                                                                                                                                                     *p<0.1; **p<0.05; ***p<0.01

i. GS10TB3Mx represents the US Treasury yield curve. Often the news will refer to “yield curve inversion” (GS10TB3Mx < 0) as a sign of a coming recession. Do you results corroborate this? Which parameter(s) lead you to that conclusion?

Most of the highly statistically significant coefficients for GS10TB3Mx are very negative. The results do not cooberate because the employment rate drops after the super negative GS10TB3Mx. My parameters are GS10TB3Mx and unrate.

(b) plot the forecasts for your variables out to 5 years in the future (20 quarters). The predict command works on your var_out object as normal.

forecast <- predict(var_out, n.ahead = 20)

plot(forecast, names = c("UNRATE", "GS10TB3Mx", "FEDFUNDS"))

i. To me it looks like unemployment stays pretty much constant.

Part 2: Structural Vector Autoregression

1. Turn your reduced-form VAR(1) from the previous box into an SVAR(1) with the following algorithm:

b <- diag(1,12)  
b[lower.tri(b, diag=TRUE)] <- NA  


svar_out <- SVAR(var_out, Bmat = b, max.iter=1000)
## Warning in SVAR(var_out, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.

2. Deriving impulse response functions is straightforward. irf_out<-irf(svar_out,impulse=”varname”,n.ahead=T)

(a) Calculate an impulse response from a tech shock out to five years by setting varname to INDPRO and T to 20

irf_tech <- irf(svar_out, impulse="INDPRO", n.ahead=20, lrtest = NULL)
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.
## Warning in SVAR(x = varboot, Bmat = b, max.iter = 1000): The B-model is just
## identified. No test possible.

3. The included plot() function does a terrible job displaying the resulting IRFs. Instead, I have used a combination of available libraries to create Figure 1. Do these results match your expectations?

The results for the IRF are far better than the VAR plot. It is what expected.

***Part: 3 Vector Error Correction Models

1. R will only estimate standard errors for SVECM models with eleven or fewer variables. We have twelve. Let’s assume Okun’s Law holds so that if we know the response of GDP we know the response of unemployment. Create a new data frame like we used for the SVAR, but drop UNRATE.

svec_vars <- subset(variables, select = -UNRATE)
svec_vars <- na.omit(svec_vars)  # Ensure no NAs

We first need to estimate how many long run relationships there are in the data. We use Johansen’s Test for this.

(a) Type vecm <- ca.jo(svec_vars, type=”trace”, ecdet = “const”, K = 2, spec=”longrun”)

library(urca)
vecm <- ca.jo(svec_vars, type="trace", ecdet="const", K=2, spec="longrun")

(b) Type summary(vecm) to get an organized list of output from Johansen’s Test.

summary(vecm)
## 
## ###################### 
## # Johansen-Procedure # 
## ###################### 
## 
## Test type: trace statistic , without linear trend and constant in cointegration 
## 
## Eigenvalues (lambda):
##  [1]  4.244765e-01  3.623027e-01  3.280448e-01  2.644437e-01  2.078169e-01
##  [6]  1.553062e-01  1.304420e-01  8.905060e-02  5.164417e-02  3.757465e-02
## [11]  1.757392e-02 -3.001199e-15
## 
## Values of teststatistic and critical values of test:
## 
##             test  10pct   5pct   1pct
## r <= 10 |   3.49   7.52   9.24  12.97
## r <= 9 |   11.04  17.85  19.96  24.60
## r <= 8 |   21.48  32.00  34.91  41.07
## r <= 7 |   39.86  49.65  53.12  60.16
## r <= 6 |   67.39  71.86  76.07  84.45
## r <= 5 |  100.64  97.18 102.14 111.01
## r <= 4 |  146.54 126.58 131.70 143.09
## r <= 3 |  207.04 159.48 165.58 177.20
## r <= 2 |  285.36 196.37 202.92 215.74
## r <= 1 |  373.99 236.54 244.15 257.68
## r = 0  |  482.83 282.45 291.40 307.64
## 
## Eigenvectors, normalised to first column:
## (These are the cointegration relations)
## 
##                     INDPRO.l2      GDPC1.l2      GCEC1.l2    PCECC96.l2
## INDPRO.l2        1.000000e+00    1.00000000  1.000000e+00     1.0000000
## GDPC1.l2         2.002974e+03  194.99101266  2.932293e+01 -2875.1923961
## GCEC1.l2        -1.826410e+01  -42.96562531  2.755937e+00   228.1103325
## PCECC96.l2      -8.970408e+02   81.51654680 -1.745068e+02  2441.4049753
## GPDIC1.l2       -5.640819e+02 -252.93249932 -4.159711e+01   331.5868467
## TOTALSLx.l2      8.266316e+00   18.17044179  4.321919e+01  -262.4733784
## FEDFUNDS.l2     -2.106141e+00    3.14617310 -2.096778e-01    -1.8423145
## PCECTPI.l2      -4.486252e+00    0.04431527  1.351608e+00     1.6835521
## USSTHPI.l2      -5.016644e-02    0.12663594  3.435979e-05    -0.8108266
## GS10TB3Mx.l2    -4.818216e+00    0.50900107 -4.095494e-01    -7.9825460
## S.P.PE.ratio.l2 -3.577552e+00   -0.55724874  6.217670e-01    -0.2176945
## constant        -6.222928e+03 -585.70998830  1.068091e+03  2919.1399685
##                     GPDIC1.l2   TOTALSLx.l2   FEDFUNDS.l2   PCECTPI.l2
## INDPRO.l2          1.00000000  1.000000e+00    1.00000000   1.00000000
## GDPC1.l2         502.01130177 -2.120893e+02   73.03882843  30.48461130
## GCEC1.l2         -27.46476178  1.392725e+02   32.20273143 -53.87025332
## PCECC96.l2      -628.78271015 -1.765257e+02 -126.21324883 -40.62407193
## GPDIC1.l2        -28.73212589  3.651843e+01    5.79402273 -18.81132510
## TOTALSLx.l2       29.81339656  6.005892e+01  -15.04685869 -29.31726316
## FEDFUNDS.l2       -2.70585030 -1.637433e+00    2.33813218  -1.04768814
## PCECTPI.l2         1.44867820  1.915667e+00    0.40051521   0.65826617
## USSTHPI.l2         0.14686007 -4.367182e-02    0.00207614   0.04184591
## GS10TB3Mx.l2       3.28254084 -3.538643e+00    5.26167015  -2.93424776
## S.P.PE.ratio.l2   -0.07896348 -1.218266e-03   -0.20560723   0.05300475
## constant         913.95529135  1.572315e+03  137.99184424 736.28271568
##                    USSTHPI.l2  GS10TB3Mx.l2 S.P.PE.ratio.l2      constant
## INDPRO.l2           1.0000000     1.0000000      1.00000000     1.0000000
## GDPC1.l2        -2209.4638163 -1436.4109695   -165.13792170 -2765.3647673
## GCEC1.l2           55.6753803   985.1048024     39.71320055   663.6893740
## PCECC96.l2       1283.9474925   829.9231846     95.12118968  1281.5198889
## GPDIC1.l2         168.0781522   367.8283905     -3.71747443   431.5600076
## TOTALSLx.l2       223.6743608  -421.2416397     -3.65785060  -269.2952872
## FEDFUNDS.l2         2.7088050   -11.0722396     -0.19291373    -5.2412064
## PCECTPI.l2          4.1547210    -7.5201586     -0.08072138    10.8194661
## USSTHPI.l2         -0.2432953     1.4344899      0.04147200     0.1481053
## GS10TB3Mx.l2        3.7857557     0.5702959     -0.16667238   -13.4516356
## S.P.PE.ratio.l2    -0.1252484    -0.7704601      0.09415229     1.0570373
## constant         5569.6611352 -1262.7767627    357.22343126  7202.8995647
## 
## Weights W:
## (This is the loading matrix)
## 
##                    INDPRO.l2      GDPC1.l2      GCEC1.l2    PCECC96.l2
## INDPRO.d       -4.290674e-03  2.371545e-03  5.431372e-02  1.434922e-02
## GDPC1.d        -7.295334e-05  1.390245e-04  1.943582e-04  1.196281e-04
## GCEC1.d        -6.561932e-05  4.752125e-05 -1.604640e-04 -4.753147e-05
## PCECC96.d      -9.373373e-05  2.986379e-05  7.903476e-05  8.856465e-05
## GPDIC1.d       -8.038770e-05  5.741374e-04  1.923099e-03  4.800575e-04
## TOTALSLx.d     -3.095627e-05 -2.951009e-05 -2.235931e-04  1.695353e-04
## FEDFUNDS.d      3.069692e-04 -8.490529e-03  3.612912e-03 -3.768421e-03
## PCECTPI.d      -1.902915e-03  5.418624e-03 -1.060618e-02 -1.864016e-03
## USSTHPI.d      -8.176206e-03 -1.177362e-01 -1.555825e-01  2.181641e-02
## GS10TB3Mx.d     6.260549e-04  6.228821e-03  3.423733e-03  1.859737e-03
## S.P.PE.ratio.d  1.531489e-02  3.815920e-02 -3.293899e-01  7.161274e-03
##                    GPDIC1.l2   TOTALSLx.l2   FEDFUNDS.l2    PCECTPI.l2
## INDPRO.d        1.714386e-02  2.712088e-02 -2.669936e-02 -3.028465e-02
## GDPC1.d         2.522346e-04  3.627435e-04 -2.133272e-04 -1.442912e-04
## GCEC1.d        -2.532795e-04  2.822785e-05  1.297853e-04  1.109922e-04
## PCECC96.d       3.001169e-04  4.275568e-04 -8.052179e-05 -1.527834e-04
## GPDIC1.d        8.252945e-04  1.691707e-06 -1.195859e-03 -1.926590e-04
## TOTALSLx.d      5.197163e-05 -1.578541e-04  6.462320e-05  9.089424e-05
## FEDFUNDS.d      3.306005e-02 -1.963933e-02 -2.057687e-02  1.266725e-02
## PCECTPI.d      -3.688934e-03 -5.044148e-03 -8.742117e-03 -4.296591e-03
## USSTHPI.d      -9.967697e-03  6.295849e-04 -8.834751e-02 -7.849126e-02
## GS10TB3Mx.d    -3.199174e-02  2.233495e-02  4.830367e-05  7.089539e-03
## S.P.PE.ratio.d  3.871180e-02  3.982434e-02 -1.278810e-02  1.140188e-02
##                   USSTHPI.l2  GS10TB3Mx.l2 S.P.PE.ratio.l2      constant
## INDPRO.d       -4.410701e-03  1.322153e-03   -1.571808e-02  3.734892e-12
## GDPC1.d        -4.440811e-06  9.313197e-06   -7.312889e-05  4.469969e-14
## GCEC1.d         5.482202e-05  2.330589e-06   -2.595424e-05  3.720492e-14
## PCECC96.d      -4.065453e-05  6.290372e-06   -8.251208e-05  2.181151e-14
## GPDIC1.d        4.759686e-05  1.105148e-05   -2.506585e-04  1.570066e-13
## TOTALSLx.d     -1.978866e-05  5.888350e-06   -1.660523e-06  7.629201e-14
## FEDFUNDS.d      6.354350e-04  1.111775e-03   -2.404806e-03 -3.606621e-12
## PCECTPI.d      -1.508513e-03  1.170717e-04   -6.218573e-04 -1.384011e-13
## USSTHPI.d       6.379480e-03 -2.559373e-03    8.427211e-03  2.059658e-11
## GS10TB3Mx.d    -1.454972e-03 -4.618873e-04    9.761272e-04  2.631532e-12
## S.P.PE.ratio.d  3.472474e-03 -1.437000e-03   -4.404603e-02 -4.462760e-13

**(c) Toward the top of the output you will see a table featuring rows of r <= ___. Starting at r=0 , compare the first column’s number with the last column’s number. If the first is bigger than the second, we have enough information to conclude there is at least that many long run relationships (zero in this first case). Proceed up until the first number is not bigger than the last. Define the row below that as your r* for the SVEC in step 5.**

**3.-5.

b <- diag(11)
b[lower.tri(b, diag=TRUE)] <- NA

lr <- matrix(NA, nrow=11, ncol=11)