market_data <- read.csv("C:/Users/nesau/Desktop/Model/hoevenaars.csv")

The first column represents the quarterly time period, and the other columns represent returns on three asset classets (stocks, bonds, and T-Bills) and three state variables that help predict asset returns (inflation, dividend yield and term spread). Our US quarterly data start in 1952:1 and end in 2008:4

The 90-day T-bill and the 10-year constant maturity yield are from the FRED website

In order to generate the yield spread, we obtain the zero-yield data from Duffee (2002). As these data are only available until 1998:4, we extended the series using the data from Gurkaynak et al (2006)

For inflation, we use the non-seasonally adjusted consumer price index for all urban consumers and all items, also from the FRED website

The real return on 3-month T-bills is constructed as the difference between the logarithmic nominal return on 3-month T-bills and logarithmic inflation

Data on stock returns and the dividend price ratio are based on the S&P Composite. The logarithmic dividend yield is included.

We construct the gross bond return series from 10 year constant maturity yields using the log-linear approximation approach.

Stock and bond return series are included in excess of the real return on the 3-month T-Bill.

The last column in the dataset corresponds to NBER contraction or expansion periods. A contractions starts the peak of a business cycle and ends at the trough, and the expansion starts at the trough and ends at the peak

# rtb = tb - inflation
# excstocks = stocks - rtb 

var_data <- data.frame(it=market_data$nomyield, rtb=market_data$realtbillret,
                       dt=market_data$dy, St=market_data$termspread,
                       xs=market_data$excstocks, xb=market_data$excbondret)
var_data <- tail(var_data, - 1) 
var_data[,2] <- as.numeric(as.character(var_data[,2]))
var_data[,5] <- as.numeric(as.character(var_data[,5]))
var_data[,6] <- as.numeric(as.character(var_data[,6]))

var_data <- var_data * 100
ave <- sapply(var_data, mean)
SD <- sapply(var_data, sd) * 2

var_data[,1] <- var_data[,1] - ave[1]
var_data[,2] <- var_data[,2] - ave[2]
var_data[,3] <- var_data[,3] - ave[3]
var_data[,4] <- var_data[,4] - ave[4]
var_data[,5] <- var_data[,5] - ave[5]
var_data[,6] <- var_data[,6] - ave[6]

library(MTS)
## Warning: package 'MTS' was built under R version 3.1.3
var_data <- var_data 
var_model <- VAR(var_data, p=1, include.mean=F, 
                 output=F)
B <- var_model$Phi
sd.vals <- sqrt(diag(var_model$Sigma))
cor.mat <- var_model$Sigma/outer(sd.vals,sd.vals)
diag(cor.mat) <- sd.vals
Sigma_hat <- cor.mat
rm(cor.mat,sd.vals)

# Table I
print(ave)
##         it        rtb         dt         St         xs         xb 
##  1.2300382  0.3117574 -3.4886721  0.3033301  1.1797858  0.1639687
print(SD)
##         it        rtb         dt         St         xs         xb 
##  1.3579504  1.3378204  0.8122017  0.5932509 14.9419443  7.8473512
# Table II
print(B)
##              [,1]         [,2]        [,3]         [,4]          [,5]
## [1,]  0.961414600 -0.002785316  0.03578645  0.079005573  0.0044469711
## [2,]  0.213506887  0.459472807 -0.03026384  0.271044054  0.0025547277
## [3,]  0.009692528 -0.012579857  0.96850609 -0.004182844 -0.0008379167
## [4,]  0.021092507 -0.008367430 -0.02528134  0.821063996 -0.0019062258
## [5,] -1.582123441  0.948602369  3.64002880  0.102640046  0.1138135488
## [6,]  0.459545656  0.387706513 -0.42292777  3.320714848 -0.0759975726
##               [,6]
## [1,]  0.0007637403
## [2,] -0.0089072699
## [3,] -0.0026540256
## [4,]  0.0027834186
## [5,]  0.2513361389
## [6,] -0.0868874990
# Table III
print(Sigma_hat)
##             [,1]        [,2]         [,3]        [,4]        [,5]
## [1,]  0.22203272 -0.34158045  0.054647223 -0.83234576 -0.03421056
## [2,] -0.34158045  0.57097579 -0.081360725  0.15866835  0.06002620
## [3,]  0.05464722 -0.08136072  0.072860093 -0.03516766 -0.98002893
## [4,] -0.83234576  0.15866835 -0.035167655  0.17399828  0.01632275
## [5,] -0.03421056  0.06002620 -0.980028926  0.01632275  7.13520311
## [6,] -0.65358150  0.39730114  0.007626237  0.14329862 -0.01574945
##              [,6]
## [1,] -0.653581500
## [2,]  0.397301138
## [3,]  0.007626237
## [4,]  0.143298620
## [5,] -0.015749451
## [6,]  3.777802424