In the assignment we look at an empirical example of Harry Markowitz’s Modern Portfolio Theory. As we increase assets to our portfolio we can reduce the volatility of the portfolio’s return. This is statistical properties of covariance.
We looked atthe connection between the volatility of a company’s stock return and it’s beta, also utilizing the properties of covariance and correlation.
Writing a function that will let us automatically download return data:
# Loading Necessary libraries
library(quantmod)
library(zoo)
library(tseries)
library(dplyr)
library(knitr)
library(dygraphs)
library(ggplot2)
# Function to calculate monthly returns on a stock
monthly_stock_returns <- function(ticker, start_year) {
# Download the data from Yahoo finance
start_year <- paste(start_year,"-01-01",collapse = "",sep="")
symbol <- getSymbols(ticker, src = 'yahoo', from = start_year,
auto.assign = FALSE, warnings = FALSE)
# Tranform it to monthly returns using the periodReturn function from quantmod
data <- periodReturn(symbol, period = 'monthly', type = 'log')
# Let's rename the column of returns to something intuitive because the column
# name is what will eventually be displayed on the time series graph
colnames(data) <- as.character(ticker)
return(data)
}
Data is downloaded at a daily price rate. The log of the ratio of the adjusted closed price of each month is then used to calculate the monthly return. This function builds upon the quantmod R package.
I chose to look at the following companies:
The yahoo finance ticker for the TA125 index is still TA100.
ta125 <- monthly_stock_returns("^TA100","2012")
elal <- monthly_stock_returns("ELAL.TA","2012")
clalbio <- monthly_stock_returns("CBI.TA","2012")
strauss <- monthly_stock_returns("STRS.TA","2012")
fnx <- monthly_stock_returns("PHOE.TA","2012")
bezeq <- monthly_stock_returns("BEZQ.TA","2012")
clal <- monthly_stock_returns("CLIS.TA","2012")
migdal <- monthly_stock_returns("MGDL.TA","2012")
teva <- monthly_stock_returns("TEVA.TA","2012")
elbit <- monthly_stock_returns("ESLT.TA","2012")
leumi <- monthly_stock_returns("LUMI.TA","2012")
vola <- c(sd(ta125),sd(elal),sd(clalbio),sd(strauss),sd(fnx),sd(bezeq),sd(clal),sd(migdal),sd(teva),sd(elbit),sd(leumi))
names(vola) <- c("TA125","elal","clalbio","strauss","fnx","bezeq","clal","migdal","teva","elbit","leumi")
kable(t(vola))
| TA125 | elal | clalbio | strauss | fnx | bezeq | clal | migdal | teva | elbit | leumi |
|---|---|---|---|---|---|---|---|---|---|---|
| 0.031469 | 0.1258715 | 0.1609502 | 0.0578711 | 0.0745591 | 0.0723128 | 0.0794524 | 0.0742777 | 0.0628512 | 0.051678 | 0.0571819 |
We will define volatility as the sample standard deviation of monthly returns. We can see that Pharma,consumer good and financial sector stocks have lower volatility than the technology and aviation sector, these would coincide with our expectations of the riskiness of these sectors. We can see that the index has the lowest volatility as expected by MPT. This makes sense with financial theory that a diversified portfolio will be less volatile than the specific underlying stocks that it is made of. Strauss is in the consumer products industry which is considered less volatile than others. Also, strauss is a big exporter and has a large and diversified portfolio of products and projects being pursued in different markets and currencies.
# 1 - Two stocks
port1 <- 0.5*teva +0.5*fnx
sd(port1)
## [1] 0.04653915
# 2 - Four stocks
port2 <- 0.25*teva +0.25*fnx + 0.25*strauss + 0.25*elbit
sd(port2)
## [1] 0.04013974
# 3 - Eight stocks
port3 <- 0.1*strauss+0.1*fnx+0.1*bezeq+0.1*clal+0.1*migdal+0.2*teva+0.2*elbit+0.1*leumi
sd(port3)
## [1] 0.04081349
As expected the volatility of a portfolio decreased we add more stocks (that aren’t perfectly correlated). However this is a marginally decreasing process.
# running regressions
capm_elal <- lm(elal~ta125)
capm_clalbio <- lm(clalbio~ta125)
capm_strauss <- lm(strauss~ta125)
capm_fnx <- lm(fnx~ta125)
capm_bezeq <- lm(bezeq~ta125)
capm_clal <- lm(clal~ta125)
capm_migdal <- lm(migdal~ta125)
capm_teva <- lm(teva~ta125)
capm_elbit <- lm(elbit~ta125)
capm_leumi <- lm(leumi~ta125)
# results
betas <- cbind(coef(capm_elal),coef(capm_clalbio),coef(capm_strauss),coef(capm_fnx),coef(capm_bezeq),coef(capm_clal),coef(capm_migdal),coef(capm_teva),coef(capm_elbit),coef(capm_leumi))
colnames(betas) <- c("elal","clalbio","strauss","fnx","bezeq","clal","migdal","teva","elbit","leumi")
rownames(betas) <- c("alpha","beta")
kable(betas)
| elal | clalbio | strauss | fnx | bezeq | clal | migdal | teva | elbit | leumi | |
|---|---|---|---|---|---|---|---|---|---|---|
| alpha | 0.0200988 | -0.0322697 | 0.0016162 | 0.0023448 | -0.0044863 | -0.0045795 | -0.0109707 | -0.0084288 | 0.0125850 | 0.0011393 |
| beta | 0.7432829 | 1.4468690 | 0.9946945 | 1.0229029 | 0.8384177 | 1.3375606 | 1.2540865 | 1.0010269 | 0.7103524 | 1.2551940 |
dat <- data.frame(Beta=betas[2,],Volatility=vola[2:11])
ggplot(dat, aes(Volatility, Beta)) + geom_point() + ggtitle("Beta as function of Volatility")
The mathematical definition of \(\beta\) is \[\beta_{i}=\rho_{i,m}\cdot\frac{\sigma_{i}}{\sigma_{m}}\]
In other words it’s the correlation between an asset’s return and the market times the ratio of standard deviation of the returns. Therefore three things can affect the \(\beta\) - the correlations and the marginal volatilities.
As seen in the formula the beta should increase with the underlying stock’s volatility, however it is scaled by the ratio of the correlation of te index and the stock and the index’s volatility. Meaning it’s not just the volatility of the stock but it’s how correlated it is to the index which affects the magnitude of the beta.
For example Pheonix and bezeq have similar volatilites but the betas are different since the corrleation with TA125 is different. Pheonix has a stronger corrleation and therefore will have a higher beta as expected.
kable(t(vola[5:6]))
| fnx | bezeq |
|---|---|
| 0.0745591 | 0.0723128 |
kable(betas[,4:5])
| fnx | bezeq | |
|---|---|---|
| alpha | 0.0023448 | -0.0044863 |
| beta | 1.0229029 | 0.8384177 |
kable(cor(fnx,ta125))
| ^TA100 | |
|---|---|
| PHOE.TA | 0.4317346 |
kable(cor(bezeq,ta125))
| ^TA100 | |
|---|---|
| BEZQ.TA | 0.3648618 |