Econ 5316 time Series Econometrics(Spring 2017) / Homework8 Problem2 Keunyoung (Kay) Kim
In this assignment, we estimate CAPM using state spate model. The standard CAPM uses a constant \(\beta\), but here we estimate time-varying coefficient, \(\alpha_t\) and \(\beta_t\) .
In this CAPM, we analyse the excess return of IBM stock and excess return of market. To get market return, we download S&P 500 index. For excess return, we also download short-term(3-month) Treasury Bill. We set the sample period from March 1984 since IBM stock return data is available from that time.
First, we estimate CAPM using simple OLS and then compare coefficients \(\alpha\) and \(\beta\) with those from Kalman filter method.
In order to calculate the excess return, we need a risk-free rate. We use monthly Treasury bill rate (\(r_t^{TB}\)) as risk-free rate.
Our CAPM for simple OLS is as follows.
\(r_t^{IBM}\) - \(r_t^{TB}\) = \(\alpha\) + \(\beta\) ( \(r_t^{SP500}\) - \(r_t^{TB}\) ) + \(\varepsilon_t\)
In this OLS result, \(\alpha\) is -0.09215 and \(\beta\) is 0.92199. \(\alpha\) is close to zero and we cannot reject null of zero \(\alpha\). Thus we can say this CAPM holds since the excess return of IBM stock can be explained by the excess return of market. \(\beta\) is close to 1 and positive. It means that IBM stock price move together with market index.
The plot below shows the relationship between excess return of IBM and S&P 500(market). The slope of this line indicates a positive value, \(\beta\) and intercept shows \(\alpha\)
##
## Call:
## lm(formula = y ~ x)
##
## Residuals:
## Min 1Q Median 3Q Max
## -31.2394 -3.3390 -0.1672 3.5691 24.5040
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -0.09215 0.30263 -0.304 0.761
## x 0.92199 0.06889 13.383 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 6.196 on 419 degrees of freedom
## Multiple R-squared: 0.2995, Adjusted R-squared: 0.2978
## F-statistic: 179.1 on 1 and 419 DF, p-value: < 2.2e-16
To estimate model with time-varying parameters easily, we use state-space model framework.
## [1] 0.02331249
## [1] 0.9221456
## [1] -0.06621224
## [1] 0.9214527
The \(\alpha\) and \(\beta\) from (b) are based on the assumption of constant coefficients. However, the \(\alpha\) and \(\beta\) from (c) are based on CAPM with time-varying coefficients. That is, these coefficients depend on the previous information. This is a form of conditional CAPM. From (b), \(\alpha\) is -0.09215 and \(\beta\) is 0.92199. That \(\alpha\) is close to zero and \(\beta\) is close to 1. But results from (C) show that \(\alpha\) is too low (close to -0.4) in 1990 or too high (close to 0.2) after late 1990’s and occasionally is different from zero. So it presents that CAPM for IBM stock does not always hold. \(\beta\) is also fluctuating. It is sometimes more sensitive (above 1.2) to market or less sensitive(below 0.8) to market. \(\beta\) measures the systematic risk of individual stock. Thus we can say the IBM stock’s risk exposure to market is varying over time. It declines after 2000 and stays around 0.75.
When we compare the OLS coefficients with the mean of filtered and smoothed coefficients, the value of \(\beta\) is similar each other, around 0.92 but \(\alpha\) is different from each other for both sign and magnitude.
Simple OLS: \(\alpha\) : -0.09215 \(\beta\) : 0.92199.
Mean of filtered coefficients: \(\alpha\) : \(0.0233125\) \(\beta\) : \(0.9221456\)
Mean of smoothed coefficients: \(\alpha\) : \(-0.0662122\) \(\beta\) : \(0.9214527\)
Based on this result, we can say that for some period, CAPM does not hold ( \(\alpha\) is not zero) and IBM stock is more volatile than market around early 2000’s.( \(\beta\) is higher than 1). The results from state space model framework provide the more information about \(\alpha\) and \(\beta\), since these values include the time-varying information. Finally, if \(\alpha\) and \(\beta\) are not constant and volatile over time, state space model framework are more appropriate to estimate the CAPM, compared to simple OLS.
library(Quandl)
Quandl.api_key("XzdSwkDsE98Mxj3ixQzG")
# Q.a: Construct the time series
sp <- Quandl("YAHOO/INDEX_GSPC/CLOSE",collapse="monthly", type="ts")
ibm <- Quandl("GOOG/NYSE_IBM/CLOSE", collapse="monthly", type="ts")
tb <- Quandl("FRED/TB3MS", type="ts")
par(mfrow=c(1,1), mar=c(4,4,2,1))
plot(cbind(sp, ibm, tb), main="Monthly data of S&P index, IBM and T-bill")
sp <- window(sp, start=c(1981,3), end=c(2016,4))
ibm <- window(ibm, start=c(1981,3), end=c(2016,4))
tb <- window(tb, start=c(1981,3), end=c(2016,4))
r.sp = 100 * diff(log(sp))
r.ibm = 100*diff(log(ibm))
r.tb= tb/12
par(mfrow=c(1,1), mar=c(4,4,2,1))
plot(cbind(r.sp, r.ibm, r.tb), main="Monthly return for S&P index, IBM and T-bill")
# Q.b : Estimate a simple OLS regression
y <- r.ibm-r.tb
x <- r.sp-r.tb
y.OLS <- lm(y ~ x)
summary(y.OLS)
plot(x, y)
abline(lm(y~x))
# Q.c: Estimate a CAPM with time-varying coefficients
T <- length(x)
Zt <- array(rbind(rep(1,T), x), dim=c(1,2,T))
Ht <- matrix(NA)
Tt <- diag(2)
Rt <- diag(2)
Qt <- matrix(c(NA,0,0,NA), 2,2)
a1 <- matrix(c(0, 1), 2, 1)
P1 <- matrix(0, 2, 2)
P1inf <- diag(2)
library(KFAS)
# define state-space CAPM model
y.SS <- SSModel(y ~ -1 + SSMcustom(Z=Zt, T=Tt, R=Rt, Q=Qt, a1=a1, P1=P1, P1inf=P1inf), H=Ht)
# estimate variances of innovations using maximum likelihood
y.SS.ML <- fitSSM(y.SS, inits = c(0.001,0.001,0.001), method="BFGS")
# Kalman filtering and smoothing, with parameters in Q and H set to maximum likelihood estimates
y.SS.KFS <- KFS(y.SS.ML$model)
# extract filtered and smoothed alpha and betta
alpha.KFS <- ts( cbind(y.SS.KFS$a[,1], y.SS.KFS$alphahat[,1]), start=c(1981,4), frequency=12)
betta.KFS <- ts( cbind(y.SS.KFS$a[,2], y.SS.KFS$alphahat[,2]), start=c(1981,4), frequency=12)
par(mfrow=c(2,2), mar=c(4,4,2,1))
# plot filtered and smoothed state alpha and betta
plot.ts(alpha.KFS, plot.type="single", xlab="",ylab="Alpha", col=c("blue","red"), lwd=2)
legend("topright", c("filtered","smoothed"), col=c("blue","red"), lwd=2, cex=0.7, bty="n")
plot.ts(betta.KFS, plot.type="single", xlab="",ylab="Beta", col=c("blue","red"), lwd=2)
legend("topright", c("filtered","smoothed"), col=c("blue","red"), lwd=2, cex=0.7, bty="n")
# plot smoothed state alpha and betta
plot.ts(alpha.KFS[,2], plot.type="single", xlab="",ylab="Alpha", col="red", lwd=2)
legend("topright", "smoothed", col="red", lwd=2, cex=0.7, bty="n")
plot.ts(betta.KFS[,2], plot.type="single", xlab="",ylab="Beta", col="red", lwd=2)
legend("topright", "smoothed", col="red", lwd=2, cex=0.7, bty="n")
#KF filtered alpha, beta
mean(y.SS.KFS$a[, 1])
mean(y.SS.KFS$a[, 2])
#KF smoothed alpha, beta
mean(y.SS.KFS$alphahat[, 1])
mean(y.SS.KFS$alphahat[, 2])