Empirical Methods in Finance Homework 5
Prof. . Lochstoer February 6, 2022
Problem 1: VAR Implementation
Use the data on quarterly excess stock market returns, the market Dividend / Price ratio, and the difference between the 10-yr Treasury yield and the Fed Funds rate in the excel spreadsheet “MktRet_DP_TermSpread.xlsx”. The interest rate data is from the FRED data depository, available online from the St. .
Copyright By PowCoder代写 加微信 powcoder
1. Plot each series. Give the sample mean, standard deviation, and first order autocor- relation of each series. From the first-order autocorrelation, calculate the half-life of each series (see ARMA notes for exact half-life formula).
Suggested Solution: Figure 1 shows the time series of market excess return. Figure 2 shows the time series of market D/P ratio. Figure 3 shows the time series of the yield of the 10-yr Treasury over the Fed Funds rate. Table 1 shows the statistics for these time series. The first-order autocorrelation (ρ1) is calculated using
Cov(xt, xt−1)
ρ1 = V ar(xt) V ar(xt−1).
At the half-life, the process is expected to revert half of the distance to the mean:
Et(xt+h − μ) = ρh1(xt − μ) = 0.5(xt − μ). We can then solve for h:
h = log(0.5)/ log(ρ1).
Time Series of Stock Returns
1960 1970 1980 1990 2000 2010 Year
Time Series of D/P Ratio
1960 1970 1980 1990 2000 2010 Year
Figure 2 2
D/P Ratio Excess Return
0.01 0.02 0.03 0.04 0.05 -0.2 -0.1 0.0 0.1 0.2
Time Series of 10-Yr Treasury yield
1960 1970 1980 1990 2000 2010 Year
Mean 0.016 s.d. 0.084 ρ1 0.070 Half Life 0.260
0.029 0.010 0.962 17.847
Yield Spread
0.011 0.017 0.804 3.176
Table 1: Data Summary
-0.06 -0.02 0.02
2. Estimate a VAR(1). Give the coefficient estimates, their White standard errors, and the R2 from each regression.
Suggested Solution: We estimate the following VAR(1) model:
rt rt−1 D/Pt = φ0 + φ1 D/Pt−1 + εt.
yt yt−1 The estimation results are the following:
φ0 = 0.002 0.002
0.049 1.451 φ1 = −0.002 0.940 −0.015 0.010
1.050 −0.039 .
The White Standard errors for the coefficients are
0.075 0.590 0.409 s.e. = 0.002 0.020 0.017 ,
0.008 0.076 0.093
and the R2 for each regression is
R2 = 0.93 .
3. Is the VAR stationary?
Suggested Solution: To check for stationarity in a VAR(1), we need to investigate the eigenvalues of φ1. We require that the modulus of the eigenvalues are all less than
0.06 0.65
one. For a complex number z = x + iy, the modulus is defined as |z| = x2 + y2.
The modulus of the three eigenvalues are (0.941 0.795 0.074) ; the VAR(1) we esti- mated is stationary.
4. What is the volatility of quarterly expected returns given the return forecasting regres- sion?
Suggested Solution:
Var(Et(rt+1))=e′1 ×φ1 ×Ω×φ′1 ×e1,
where Ω = Var(zt), zt = [rt,DPt,yt]′, and e1 = [1,0,0]′. The variance of quarterly expected returns is 0.0004; the standard deviation is 0.02. Note that this is similar to recognising that
rt = φ1,1rt−1 + φ1,2dpt−1 + φ1,3yt−1 + εt. Taking conditional expectations one period ahead:
Et[rt+1] = φ1,1rt + φ1,2dpt + φ1,3yt.
Then, remembering that
V ar(φ1,1rt+φ1,2dpt+φ1,3yt) = φ21,1V ar(rt)+φ21,2V ar(dpt)+φ21,3V ar(yt)+2φ1,1φ1,2Cov(rt, dpt)+…
5. Plot the one-quarter ahead expected return series. Plot the four quarters ahead ex- pected return series. Plot the twenty quarters ahead expected return series. Comment on how the persistence of the term spread and the DP-ratio affects the expected return forecasts at different horizons.
Suggested Solution: Figure 4 shows the time series of predictions of returns for various horizons. The D/P ratio is persistent while the other time series are not, so that looking 20 periods ahead, virtually all the variation in the return is driven by changes in the D/P ratio, as can be seen from Figure 5.
Predictions
Et (rt+1 ) Et (rt+4 ) Et (rt+20 )
1960 1970 1980 1990 2000 2010 Year
Twenty Periods Ahead Prediction
1960 1970 1980 1990 2000 2010 Year
Et (rt+20 ) DP Ratio
Figure 5 6
Excess Return Excess Return 0.00 0.02 0.04 -0.04 0.00 0.04
6. Plot the impulse-response function for returns from a one standard deviation positive shock from each of the three shocks in turn using 20 lags. You can do this by simulation. Start at unconditional averages for the lagged values of all the variables in the VAR (time t−1). Then set the time t shock in row 1 of the VAR to its one standard deviation value, and set all other current and future shocks to zero. Trace out the response by simulating future variables using the VAR dynamics. That’s the impulse-response for the first shock. Then go to the second shock and repeat the procedure just outlined for the first shock, but now set the second shock to its one standard deviation value and all other shocks to zero, etc.
(it is best to plot the orthogonalized shock version of impulse-response (order the shocks Term Spread, D/P. and Returns), but it is also fine if you do it the simple way. The orthogonalized impulse-response math is given in the appendix)
Suggested Solution: Figure 6 − 7 shows the direct and orthogonalized impulse re- sponses for 20 periods.
7. Using 80% of the data as a training sample, report results from an out-of-sample test for predicting excess market returns where you re-estimate the model at each time t and get the prediction error for the t+1 realizations.
Suggested Solution: Figure 7 shows the prediction results where the black line is the actual market excess return and the blue line is the predicted value. The RMSE is 0.08. We use the following equation to compare our model prediction with actual out of sample mean:
2 E(pred − actual)2
R =1− 2 =0.006.
E(actual − E(actual))
However, as we don’t know the actual out-of-sample mean when doing prediction, using this as a benchmark may not be precise. Alternatively, we can use the sample mean up until time t as a prediction benchmark:
pred2t+1 = mean(sample[1 : t]). We then calculate the R2 in the alternative way :
2 E(pred − actual)2
R =1− 2 =−0.01.
E(actual − pred2)
Figure 8: Predicted vs.Actual Returns
library(data.table)
library(sandwich)
library(DataAnalytics)
library(expm)
myData<-MktRet_DP_TermSpread
plot(myData$MktExRet~myData$Date,type="l",main="Time Series of Stock Return")
plot(myData$Mkt_DP~myData$Date,type="l",main="Time Series of D/P Ratio")
plot(myData$y10minFedFunds~myData$Date,type="l",main="Time Series of Yield Spread")
apply(myData[,2:4],2,mean)
apply(myData[,2:4],2,sd)
myData$lagMkt=c(NA,myData$MktExRet[1:(nrow(myData)-1)])
a=cor(myData$lagMkt[2:nrow(myData)],myData$MktExRet[2:nrow(myData)])
myData$lagDP=c(NA,myData$Mkt_DP[1:(nrow(myData)-1)])
b=cor(myData$lagDP[2:nrow(myData)],myData$Mkt_DP[2:nrow(myData)])
myData$lagY=c(NA,myData$y10minFedFunds[1:(nrow(myData)-1)])
c=cor(myData$lagY[2:nrow(myData)],myData$y10minFedFunds[2:nrow(myData)])
h1=log(0.5)/log(a)
h2=log(0.5)/log(b)
h3=log(0.5)/log(c)
#problem 2-2
library(MTS)
reg1=lm(myData$MktExRet~myData$lagMkt+myData$lagDP+myData$lagY)
reg2=lm(myData$Mkt_DP~myData$lagMkt+myData$lagDP+myData$lagY)
reg3=lm(myData$y10minFedFunds~myData$lagMkt+myData$lagDP+myData$lagY)
sapply(X=list(reg1,reg2,reg3), FUN=lmSumm, HAC=TRUE)
#problem 2-3
phi1=matrix(NA,3,3)
phi1[1,]=reg1$coefficients[2:4]
phi1[2,]=reg2$coefficients[2:4]
phi1[3,]=reg3$coefficients[2:4]
eigen(phi1)$values
#problem 2-4
var=phi1[1,1]^2*var(myData$lagMkt,na.rm=TRUE)+phi1[1,2]^2*var(myData$lagDP,na.rm=TRUE)
+phi1[1,3]^2*var(myData$lagY,na.rm=TRUE)+2*phi1[1,1]*phi1[1,2]*cov(myData$lagMkt[-1],
myData$lagDP[-1])+2*phi1[1,1]*phi1[1,3]*cov(myData$lagMkt[-1],myData$lagY[-1])+2*phi1[1,
*phi1[1,2]*cov(myData$lagY[-1],myData$lagDP[-1])
#problem 2-5
phi0=matrix(NA,3,0)
phi0[1]=reg1$coefficients[1]
phi0[2]=reg2$coefficients[1]
phi0[3]=reg3$coefficients[1]
library(expm)
mu<-solve(diag(3)-phi1)%*%phi0
zt=myData[2:4]
zt=zt-kronecker(matrix(1,nrow(zt),1),t(mu))
Et1<-t(phi1%*%t(zt))+kronecker(matrix(1,nrow(zt),1),t(mu))
Et4<-t((phi1%^%4)%*%t(zt))+kronecker(matrix(1,nrow(zt),1),t(mu))
Et20<-t((phi1%^%20)%*%t(zt))+kronecker(matrix(1,nrow(zt),1),t(mu))
plot(Et1[,1],main="One Period Ahead Prediction",type="l")
plot(Et4[,1],main="Four Periods Ahead Prediction",type="l")
plot(Et20[,1],main="Twenty Periods Ahead Prediction",type="l")
stDevs=matrix(NA,3,1)
stDevs[1]=sd(reg1$residuals)
stDevs[2]=sd(reg2$residuals)
stDevs[3]=sd(reg3$residuals)
#problem 2-6
imp=matrix(NA,21,3)
for (j in 1:3){
for(i in 1:21){
imp[i,j]=(phi1%^%(i-1))[1,j]*stDevs[j]
plot(imp[1:21,1],type="l",main=" ",xlab="Periods",ylim=c(-0.002,0.01))
lines(imp[1:21,2],type="l",col="blue")
lines(imp[1:21,3],type="l",col="red")
legend("topright",legend=c("Return Shock","DP Shock","Spread Shock"),col=c("black","blue
#problem 2-7
myData=myData[-1,]
N<-nrow(myData[,1])
train<-round(N*4/5)
pred=matrix(NA,N-train,1)
actual=myData[(train+1):N,2]
for(i in train:(N-1)){
reg=lm(MktExRet~lagMkt+lagDP+lagY,data=myData[1:i,])
pred[1+i-train]=reg$coefficients[1]+reg$coefficients[2]*myData[i,2]+
reg$coefficients[3]*myData[i,3]+reg$coefficients[4]*myData[i,4]
pred<-unlist(pred)
actual=data.frame(actual)
temp=cbind(actual,pred)
names(temp)[1] <- "actual"
MSE=mean((temp$actual-temp$pred)^2)
RMSE=sqrt(MSE)
R2=1-MSE/var(temp$actual)
alt=rep(0,N-train)
for(i in train:(N-1)){
alt[1+i-train]=colMeans(myData[1:i,2])
temp=cbind(temp,alt)
MSE_a=mean((temp$actual-temp$alt)^2)
R2_a=1-MSE/MSE_a
plot(temp$actual,type="l")
lines(temp$pred,type="l",col="blue")
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com