# Tag Archives: frontiers

To make the connection between the traditional mean variance framework and the equilibrium condition embodied by the CAPM more tangible,  a quick and more concrete supplement to the previous post may be helpful. Instead of simulating asset characteristics and subsequently feeding these as inputs into the optimisation process, we will simply assume a particular set of asset returns, impose a variance structure among these and find the minimum variance and tangency portfolios formulaically. To simplify this process, several functions are written to once again draw the frontiers,capital allocation lines and locate assets/portfolios of interest.

p

```###################################################################################################
###################################################################################################
#Supplement
###################################################################################################
###################################################################################################

Frontiers <- function (data.obj){
er <- t(data.obj\$mean.ret)
risk.free <- data.obj\$risk.free
cov.mat <- data.obj\$cov.matrix
ones <- rep(1, length(er))
target <- seq(0,1,length.out=100)
top <- cbind(2*cov.mat, er, ones)

temp<-rbind(t(er), ones)
bot <- cbind(temp, matrix(0,2,2))
A <- rbind(top, bot)
w<-matrix(0,nrow=length(target),ncol=length(er))
er.port <- matrix(0,nrow=length(target),ncol=1)
sd.port <- matrix(0,nrow=length(target),ncol=1)

for (i in 1:length(target)){
b.target <- as.matrix(c(rep(0, length(er)), target[i], 1))
x <- solve(A, b.target)
w[i,] <-x[1:length(er)]
er.port[i] <- crossprod(er,w[i,])
sd.port[i] <- sqrt(w[i,] %*% cov.mat %*% w[i,])
}

cov.mat.inv <- solve(cov.mat)
w.t <- cov.mat.inv %*% (er - risk.free)
w.t <- as.vector(w.t/sum(w.t))
er.t <- crossprod(w.t,er)
sd.t <- sqrt(t(w.t) %*% cov.mat %*% w.t)

frontiers.data <-	list()
frontiers.data\$weights <- w
frontiers.data\$port.ret <- er.port
frontiers.data\$port.risk <- sd.port
frontiers.data\$tang.weights <- w.t
frontiers.data\$tang.ret <- er.t
frontiers.data\$tang.risk <- sd.t
return(frontiers.data)
}

CAL.Draw <- function(data.obj,frontiers.data,colour,lty){
total.risk <- seq(0,1,by=0.01)
risk.free <- data.obj\$risk.free
asset.return <- frontiers.data\$tang.ret
asset.risk <- frontiers.data\$tang.risk

price.risk <-c()
total.return <-matrix(rep(0,length(total.risk)),nrow=length(total.risk),ncol=1)
price.risk <- (asset.return-risk.free)/asset.risk
total.return <- risk.free+(price.risk*total.risk)
CAL.complete<-cbind(total.risk,total.return)

lines(CAL.complete,col=colour,type='l',lwd=1,lty=lty)
points(x=asset.risk,y=asset.return,pch=17,col=colour)
text(labels='Tangency\nPortfolio',x=asset.risk,y=asset.return,pos=3,col='black',cex=0.65)

}

par(xaxs="i", yaxs="i")
plot(main=title,xlim=c(0,0.2),ylim=c(min(data.obj\$mean.ret)-0.3,max(data.obj\$mean.ret)+0.3),x=frontiers.data\$port.risk,y=frontiers.data\$port.ret,lty=lty,type='lines',col=colour,lwd=1.5,xlab='Portfolio Risk',ylab='Portfolio Return',cex.lab=0.75,cex.axis=0.7,cex.main=0.75)
lines(x=frontiers.data\$port.risk,y=frontiers.data\$port.ret,type='lines',col=colour,lwd=1.5,main='',xlab='Portfolio Risk',ylab='Portfolio Return',cex.lab=0.7,cex.axis=0.7)
}
points(x=sqrt(diag(data.obj\$cov.matrix)),y=data.obj\$mean.ret,col=colour,pch=19)
points(x=0.001,y=data.obj\$risk.free,pch=15,col='dark green')
text(labels=paste('Asset',1:length(data.obj\$mean.ret)),x=sqrt(diag(data.obj\$cov.matrix)),y=data.obj\$mean.ret,pos=4,col='black',cex=0.65)
text(labels='risk free\nasset',x=0.001,y=data.obj\$risk.free,pos=4,col='black',cex=0.65)
}
```

l

The objective is to sketch some of the implications of the CAPM in the context of the mean variance framework, particularly with respect to the frontiers that would result when markets are in (dis) equilibrium. The base case involves 2 risky assets, the minimum variance frontier that results from these two assets,the tangency portfolio (combination of these assets that maximises the Sharpe ratio) as well as the risk free asset and the capital allocation line ( combination of the risk free asset with the tangency portfolio). Once this basic case has been established, the effect of adding a third risky asset to the universe of investable assets will be examined in terms of the resulting shifts in the recalculated frontiers/lines and changes in tangency portfolios. To implement these issues :

r

```###########################################################################
#
# Quick Implentations
#
############################################################################</pre>
windows()
layout(matrix(c(1,2,3,4),ncol=2,nrow=2,byrow=T))
par(mar=c(4,4,3,1))

#base case
two.asset.data <- list()
two.asset.data\$mean.ret <- matrix(c(0.800,0.0500),nrow=1,ncol=2,dimnames=list(c('mean return'),c('asset 1','asset 2')))
two.asset.data\$cov.matrix <- matrix(c(0.0256,0,0,0.0144),nrow=2,ncol=2,byrow=T,dimnames=list(c('asset 1','asset 2'),c('asset 1','asset 2')))
two.asset.data\$risk.free <- 0.02
b.ret <- two.asset.data\$mean.ret[2]
b.var <- two.asset.data\$cov.matrix[2]

base<-Frontiers(two.asset.data)
Frontier.Draw(two.asset.data,base,c('red','blue'),'new',lty=1,'Base Case\n2 Risky Assets')
CAL.Draw(two.asset.data,base,'black',lty=1)

#new asset with alpha of 0
Frontier.Draw(two.asset.data,base,c('red','blue'),'new',lty=1,'New Asset\nAlpha = 0')
CAL.Draw(two.asset.data,base,'black',lty=1)

z.data <- list()
z.data\$mean.ret <- matrix(c(0.800,0.0500,0+b.ret),nrow=1,ncol=3,dimnames=list(c('mean return'),c('asset 1','asset 2','asset 3')))
z.data\$cov.matrix <- matrix(c(0.0256,0,0,0,0.0144,0,0,0,0.0144),nrow=3,ncol=3,byrow=T,dimnames=list(c('asset 1','asset 2','asset 3'),c('asset 1','asset 2','asset 3')))
z.data\$risk.free <- 0.02

th<-Frontiers(z.data)
CAL.Draw(z.data,th,'dark green',2)

#new asset with alpha of -0.2
Frontier.Draw(two.asset.data,base,c('red','blue'),'new',lty=1,'New Asset\nAlpha = -0.2')
CAL.Draw(two.asset.data,base,'black',lty=1)

z.data <- list()
z.data\$mean.ret <- matrix(c(0.800,0.0500,-0.2+(b.ret)),nrow=1,ncol=3,dimnames=list(c('mean return'),c('asset 1','asset 2','asset 3')))
z.data\$cov.matrix <- matrix(c(0.0256,0,0,0,0.0144,0,0,0,0.0144),nrow=3,ncol=3,byrow=T,dimnames=list(c('asset 1','asset 2','asset 3'),c('asset 1','asset 2','asset 3')))
z.data\$risk.free <- 0.02

th<-Frontiers(z.data)
CAL.Draw(z.data,th,'dark green',2)

#new asset with alpha of +0.5
Frontier.Draw(two.asset.data,base,c('red','blue'),'new',lty=1,'New Asset\nAlpha = 0.5')
CAL.Draw(two.asset.data,base,'black',lty=1)

z.data <- list()
z.data\$mean.ret <- matrix(c(0.800,0.0500,0.5+(b.ret)),nrow=1,ncol=3,dimnames=list(c('mean return'),c('asset 1','asset 2','asset 3')))
z.data\$cov.matrix <- matrix(c(0.0256,0,0,0,0.0144,0,0,0,0.0144),nrow=3,ncol=3,byrow=T,dimnames=list(c('asset 1','asset 2','asset 3'),c('asset 1','asset 2','asset 3')))
z.data\$risk.free <- 0.02

th<-Frontiers(z.data)
CAL.Draw(z.data,th,'dark green',2)

#Gif 1
id <- seq(-0.25,0.95,by=0.015)
l <- length(id)

png(file="example%02d.png", width=600, height=500)
for(i in 1:l){
layout(matrix(c(1,1,1,2,1,1,1,3,1,1,1,4),3,4,byrow=T))
par(mai=c(0.7,0.3,0.5,0.3))
Frontier.Draw(two.asset.data,base,c('red','blue'),'new',lty=1,paste('New Asset\nAlpha =', id[i]))
CAL.Draw(two.asset.data,base,'black',lty=1)

z.data <- list()
z.data\$mean.ret <- matrix(c(0.800,0.0500,id[i]+(b.ret)),nrow=1,ncol=3,dimnames=list(c('mean return'),c('asset 1','asset 2','asset 3')))
z.data\$cov.matrix <- matrix(c(0.0256,0,0,0,0.0144,0,0,0,0.0144),nrow=3,ncol=3,byrow=T,dimnames=list(c('asset 1','asset 2','asset 3'),c('asset 1','asset 2','asset 3')))
z.data\$risk.free <- 0.02

th<-Frontiers(z.data)
CAL.Draw(z.data,th,'dark green',2)

par(mai=c(0.5,0.1,0.5,0.5))
stackpoly(col=c('red','blue','dark green'),cex=0.75,cex.axis=0.8,cex.lab=0.8,cex.main=0.8,th\$weights,xlab='Portfolios on the frontier',main='Frontier weights')
par(mai=c(0.5,0.1,0.5,0.5))
barplot(cex=0.75,cex.axis=0.8,cex.lab=0.8,cex.main=0.8,space=0,beside=T,th\$tang.weights,col=c('red','blue','dark green'),ylab='Weights',xlab='Risky assets',main='Tangency Portfolio')
plot.new()
par(mai=c(0.7,0.1,0.5,0.5))
legend('top',fill=c('red','blue','dark green'),legend=c(paste('Asset',1:3)),ncol=1,bg='white',bty='n',cex=0.85)

}
dev.off()
shell("convert -delay 10 *.png example_1.gif")

#gif 2
id <- seq(0.001,0.0256,by=0.001)
l <- length(id)

png(file="bobo%02d.png", width=600, height=500)
for(i in 1:l){
layout(matrix(c(1,1,1,2,1,1,1,3,1,1,1,4),3,4,byrow=T))
par(mai=c(0.7,0.3,0.5,0.3))
Frontier.Draw(two.asset.data,base,'red','new',lty=1,paste('New Asset\nRisk =', id[i]))
CAL.Draw(two.asset.data,base,'red',lty=1)

z.data <- list()
z.data\$mean.ret <- matrix(c(0.800,0.0500,b.ret),nrow=1,ncol=3,dimnames=list(c('mean return'),c('asset 1','asset 2','asset 3')))
z.data\$cov.matrix <- matrix(c(0.0256,0,0,0,0.0144,0,0,0,id[i]),nrow=3,ncol=3,byrow=T,dimnames=list(c('asset 1','asset 2','asset 3'),c('asset 1','asset 2','asset 3')))
z.data\$risk.free <- 0.02

th<-Frontiers(z.data)
CAL.Draw(z.data,th,'dark green',2)

par(mai=c(0.5,0.1,0.5,0.5))
stackpoly(col=c('red','blue','dark green'),cex=0.75,cex.axis=0.8,cex.lab=0.8,cex.main=0.8,th\$weights,xlab='Portfolios on the frontier',main='Frontier weights')
par(mai=c(0.5,0.1,0.5,0.5))
barplot(cex=0.75,cex.axis=0.8,cex.lab=0.8,cex.main=0.8,space=0,beside=T,th\$tang.weights,col=c('red','blue','dark green'),ylab='Weights',xlab='Risky assets',main='Tangency Portfolio')
plot.new()
par(mai=c(0.7,0.1,0.5,0.5))
legend('top',fill=c('red','blue','dark green'),legend=c(paste('Asset',1:3)),ncol=1,bg='white',bty='n',cex=0.85)

}
dev.off()

shell("convert -delay 10 *.png bobo_1.gif")
<pre>
```

f

The third asset that will be added to the initial investable universe (comprising of two assets) will be related to the CAPM with one of the following restrictions:

[1] Alpha is 0

1. The expected return on the asset is correctly related to the tangency portfolio.
2. No mispricing of the security relative to the level predicted by the CAPM.
3. CAPM holds
4. Equilibrium prevails.

[2] Alpha is -0.2

1. The expected return on the new asset is inconsistent with the CAPM return.
2. Mispricing of the security; the expected return of the asset is lower than that predicted by the CAPM by 0.2. This implies that the asset is overvalued by the market in terms of price and mean reversion in the future would dictate the asset price to decrease (returns to increase) until the CAPM-consistent level is reached.
3. CAPM fails.
4. Markets are in disequilibrium because the original two asset tangency portfolio can be improved upon by shorting the new asset and reaching a new tangency portfolio with a higher sharpe ratio (or CAL slope)

[3] Alpha is +0.5

1. The expected return on the new asset is inconsistent with CAPM returns.
2. Mispricing of the security; the expected return of the asset is higher than that predicted by the CAPM by 0.5. This implies that the asset is undervalued by the market in terms of price and mean reversion in the future would dictate a rise in asset price (returns to decrease) until the CAPM-consistent level is reached.
3. CAPM fails.
4. Markets are in disequilibrium because the original two asset tangency portfolio can be improved upon by taking a long position in the new asset and thereby reaching a new tangency portfolio with a higher sharpe ratio (steeper CAL slope).

The topleft plot depicts the situation of two risky assets; the remaining plots show the effect of adding a third risky asset to the universe of investable assets.  In all three cases, the minimum variance frontier after inclusion of the third asset,shifts to the left, implying an expanded set of investment opportunities in the presence of 3 assets versus the initial scenario of only 2 investable securities. More succinctly, the investment combinations available when there are more securities in the market are such that the resulting portfolios confer to the investor the same return for less risk. In this particular case, since the covariance matrix has been constructed to affect zero correlation across all three assets, adding a new risky asset clearly confers diversification benefits which would otherwise be either less pronounced or non-existent should the correlation across said risky assets be closer to +1 or achieve equivalence with this extreme.

Adding a CAPM consistent asset (alpha=0) to the existing universe of two stocks would not incentivise investors to change the composition of their tangency portfolio given that the resulting sharpe ratio of the new tangency portfolio would remain unchanged. In the light of the previous post, when the CAPM holds and markets are in equilbrium, the marginal benefit to cost ratio of all stocks are identical and investors would have no reason to change portfolio composition. The notion of an unchanged sharpe ratio can be visually confirmed by the overlay of the old and new capital allocation lines (whose slopes are essentially the highest sharpe ratio achievable through a combination of available risky assets).

Adding an asset that is overvalued (alpha=-0.2) to the initial scenario amounts to identifying an asset whose price is expected to decrease in the future. Rational investors would naturally short this asset in anticipation of future downward revisions in price. The slope of the new capital allocation line increases, indicating a higher sharpe ratio being conferred to the new tangency portfolio in which the third asset is held with a negative weight. Visually, the new tangency portfolio is located to the right of the original tangency portfolio, implying greater risk and returns, perhaps on account of the short position associated with the new asset.

Adding an asset that is undervalued (alpha=0.5) to the base case would alert investors to the existence of an asset whose price is expected to increase if and when future price reversions occur. Rational investors would naturally take a long position in such an asset. The slope of the new capital allocation line is higher than the original one implying a superior sharpe ratio being conferred to the new optimal risky portfolio.

¤I have updated this post with the following animations which show how tangency weights as well as generic portfolio weights on the minimum variance frontier change when the third asset’s mean return (risk) is varied while keeping variance constant (mean return constant).