To operationalise the preceding Mean-Variance analysis, estimates of asset returns and variances are required. Given the expected returns and variance/covariance matrix, the procedure determines an optimal portfolio from a selection of portfolios available on the mean-variance-frontier. Since Expected returns are relatively difficult to forecast, a model of what returns should be, on a normatively meaningful basis, will be of value.

The CAPM is an equilibrium model specifying a relation between expected returns and covariances for all assets. Equilibrium characterises a situation in which investors have no incentive to deviate from their current condition. Despite the empirical controversies surrounding CAPM estimates and the validity of the equilibrium argument, it should be noted that the Markowitz procedure itself remains relevant and instructive for most investors.

This post will continue to sketch a small selection of the main results in asset pricing. Here the CAPM shall be (loosely) derived from the Mean-Variance analysis touched upon in the preceding section. Implications of the validity/failure of the model will be examined using simulated data in the context of

f

- Security Characterisitic Lines (SCL)
- A time series regression which plots the excess asset return against the excess market return.

- Security Market Lines (SML)
- A cross section regression which plots the average excess asset returns against the slope coefficient obtained from the time series regression above.

- Mean Variance Contours
- Variation in the mean variance contours on the basis of whether or not CAPM holds for a simulated asset.

l

**[The Capital Asset Pricing Model]**

Derivation of the CAPM relationship requires a set of assumptions to hold:

- No Transaction Costs
- All assets are tradable and are infinitely divisible
- No Taxes
- No individual can affect security prices
- Investors care exclusively about expected returns and variances
- Returns are normally distributed
- Investors have a quadratic utility function
- Unlimited short selling
- Unlimited borrowing and lending
- Homogeneous expectations.

Assumptions 5-10 imply that every investor solves the identical optimal risky portfolio problem delineated in the previous post. This implies that all investors draw the same **CAL** and see the same efficient frontier. This aggregate **CAL** which is identical across all agents is called the **Capital Market Line (CML)**.

The **CAPM** or its graphical counterpart in the **SML** essentially emerges as relation between expected asset returns and risk when [1] Markowitz considerations regarding the tangency portfolio and [2] Equilibrium notions are combined

p

**::Markowitz Considerations :**

One implication of the two fund theorem sketched previously is that all investors must want to hold the market portfolio (tangency portfolio) since it maximises the sharpe-ratio. Assuming that every investor faces the same universe of assets and operates under the same assumptions listed above, then each individual would rationally draw the same efficient frontier,the same **CAL** and hold the same tangency portfolio. While the amount of capital invested in the risk free asset versus this tangency portfolio may vary across individuals on the basis of risk preferences, the composition of the tangency portfolio is identical across all agents.

p

**:: Equilibrium Considerations :**

Intuitively, an equilibrium describes a condition in which every investor is content with their portfolio holdings. If the opposite were true, investors would adjust the composition of assets within their portfolio (i.e.demanding assets that are undervalued,supplying assets that are overvalued by the market) hence affecting asset prices. This implies that in equilibrium everyone must be optimally invested and nothing can be done to increase the Sharpe ratio of the current portfolio. If no investor is incentivised to change his portfolio composition, there is no scope for increasing the sharpe-ratio of the optimal portfolio being currently held.

k

**:: Intuition For The Standard CAPM :**

Investors will only hold a security in their portfolio if its marginal return (the additional excess return from holding an extra unit of the security in the portfolio) can be justified given its marginal risk (the additional volatility from holding an extra unit of the security in the portfolio). If equilibrium characterises a condition in which no investor wishes to alter portfolio composition, it must be the case that assets in the investable universe do not command a marginal benefit that compensates sufficiently for the marginal cost derived from their inclusion. Or more formally, it must be the case that for example :

In equilibrium, it must be the case that the marginal benefit to cost ratio is identical across all assets. Otherwise, investors could benefit from shifting assets in their portfolio. Intuitively, if the marginal benefit to cost ratio of GM were greater (less) than that of the market portfolio, an investor would be incentivised to increase (decrease) his holding of GM in the optimal portfolio. Hence only in equilibrium, where the ratio is identical across assets, will the rational investor be content with the current condition and not alter portfolio composition.

Summarily, according to Markowtiz, investors should hold the tangency portfolio ; Equilibria concerns imply investors must want to hold the tangency portfolio ; **CAPM** implies that the tangency portfolio is the market portfolio.

**SML**(graphical representation of the

**CAPM**essentially), the previous expression can be altered to yield

Adding the risk free asset on both sides would yield the standard CAPM.

To illustrate the difference between CAPM consistent and inconsistent assets and some of the relevant implications, the following functions are created : *DrawSecurityLines *, *CAPM.Frontiers and Fitting.model*

**It should be noted that portfolio optimisation was changed from before to include the short sales option.**

################################################################################################### # # Market Lines # ################################################################################################### DrawSecurityLines <- function(risky.assets,frontier.points,fitted.results){ assets.ret <- risky.assets[[1]] assets.mean.ret <- risky.assets[[5]] risk.free <- risky.assets[[4]] shock <- risky.assets[[6]] num.assets <- ncol(assets.ret) num.obs <- nrow(assets.ret) tangency.sharpe.ret <- frontier.points[[4]][1] tangency.weights <- as.matrix(frontier.points[[4]][-(1:3)]) tangency.excess.ret <- fitted.results[[3]] assets.excess.ret <- assets.ret - risk.free #Consistent with CAPM alphas.raw <- as.matrix(fitted.results[[1]][[1]][1,]) alphas.pvalue <- matrix(0,dimnames=list(c('P-values:'),c(paste('Asset:',1:num.assets))),ncol=num.assets) alphas.adj <- matrix(0,dimnames=list(c('P-values:'),c(paste('Asset:',1:num.assets))),ncol=num.assets) for(i in 1:num.assets){ alphas.pvalue[i] <- (summary(fitted.results[[1]])[[i]])$coefficients[1,4] } betas.raw <- as.matrix(fitted.results[[1]][[1]][2,]) betas.pvalue <- matrix(0,dimnames=list(c('P-values:'),c(paste('Asset:',1:num.assets))),ncol=num.assets) for(i in 1:num.assets){ betas.pvalue[i] <- (summary(fitted.results[[1]])[[i]])$coefficients[2,4] } fitted.vals <- fitted.results[[1]]$fitted.values capm.consistent <- matrix(dimnames=list(c(paste('Obs:',1:num.obs)),c(paste('Asset',1:num.assets))),0,nrow=num.obs,ncol=num.assets) for(i in 1: num.assets){ capm.consistent[,i] <- alphas.adj[i]+betas.raw[i]*tangency.excess.ret } avg.ret <- colMeans(assets.excess.ret) fitted.new <- lm (avg.ret~betas.raw) avg.fitted.ret <- fitted.new$fitted.values col.ind <- rainbow(num.assets) #InConsistent with CAPM capm.inconsistent <- matrix(dimnames=list(c(paste('Obs:',1:num.obs)),c(paste('Asset',1:num.assets))),0,nrow=num.obs,ncol=num.assets) for(i in 1: num.assets){ capm.inconsistent[,i] <- assets.ret[,i]+shock[,i] } in.assets.excess.ret <- capm.inconsistent-risk.free in.fitted <- lm(in.assets.excess.ret~tangency.excess.ret) in.alphas <- as.matrix(in.fitted[[1]][1,]) in.betas <- as.matrix(in.fitted[[1]][2,]) in.fitted.vals <- in.fitted$fitted.values avg.ret.c <- colMeans(in.assets.excess.ret) fitted.new.c <- lm(avg.ret.c~in.betas) avg.fitted.ret.c <- fitted.new.c$fitted.values #Characteristic Lines if CAPM held windows() layout(matrix(c(1,1,1,1,2,2,3,3)),3,2) par(mar=c(4,4,2.5,1)) plot.y.min <- min(fitted.results[[1]]$fitted.values)-0.1 plot.y.max <- max(fitted.results[[1]]$fitted.values)+0.1 plot(ylim=c(plot.y.min,plot.y.max),col=col.ind[1],xlim=c(min(tangency.excess.ret)-0.2,max(tangency.excess.ret)),xlab='Excess MVE returns',ylab='Excess asset returns',x=tangency.excess.ret,y=assets.excess.ret[,1],type='p',pch=21,cex=0.55,axes=T,cex.main=0.85,cex.lab=0.80,main='Security Characteristic Lines \n (when CAPM holds)') abline(v=0) for(i in 2: num.assets){ points(col=col.ind[i],x=tangency.excess.ret,y=assets.excess.ret[,i],type='p',pch=21,cex=0.55) } for(i in 1:num.assets){ lines(x=tangency.excess.ret,capm.consistent[,i],col=col.ind[i],lwd=1) } legend(title='Simulated Assets',"topleft",fill=c(col.ind),legend=c(paste('Asset:',1:num.assets)),bg='white',bty='n',border='white',cex=0.75) par(mar=c(0.5,4,1,1)) barplot(inside=T,col=col.ind,alphas.adj,horiz=F,beside=T,ylab='Alphas',xlab=NULL,cex=0.75,cex.main=0.85,cex.axis=0.75,cex.lab=0.75) par(mar=c(1.5,4,0.5,1)) barplot(inside=T,col=col.ind,betas.raw,horiz=F,beside=T,ylab='Betas',xlab=NULL,cex=0.75,cex.main=0.85,cex.axis=0.75,cex.lab=0.75) #Characterisitic lines if CAPM failed windows() layout(matrix(c(1,1,1,1,2,2,3,3)),3,2) par(oma=c(0,0,0,0),mar=c(4,4,2.5,1)) plot(ylim=c(plot.y.min,plot.y.max),col=col.ind[1],xlim=c(min(tangency.excess.ret)-0.2,max(tangency.excess.ret)),xlab='Excess MVE returns',ylab='Excess asset returns',x=tangency.excess.ret,y=capm.inconsistent[,1],type='p',pch=21,cex=0.55,axes=T,cex.main=0.85,cex.lab=0.75,main='Security Characteristic Lines \n (when CAPM does not hold)') abline(v=0) for(i in 1:num.assets){ lines(x=tangency.excess.ret,y=in.fitted.vals[,i],col=col.ind[i],lwd=1) } legend(xpd=NA,xjust=0,title='Simulated Assets',"topleft",fill=c(col.ind),legend=c(paste('Asset:',1:num.assets)),bg='white',bty='n',border='white',cex=0.75) par(mar=c(0.5,4,1,1)) barplot(inside=T,col=col.ind,in.alphas,horiz=F,beside=T,ylab='Alphas',xlab=NULL,cex=0.75,cex.main=0.85,cex.axis=0.75,cex.lab=0.75) par(mar=c(1.5,4,0.5,1)) barplot(inside=T,col=col.ind,in.betas,horiz=F,beside=T,ylab='Betas',xlab=NULL,cex=0.75,cex.main=0.85,cex.axis=0.75,cex.lab=0.75) #Security Market Line using fitted data (CAPM holds) windows() par(oma=c(0,0,0,0)) sml.matrix <- matrix(dimnames=list(c(paste('Asset:',1:num.assets)),c('Beta','Expected Return')),c(betas.raw,avg.ret),byrow=F,nrow=num.assets,ncol=2) plot(xlab=colnames(sml.matrix)[1],ylab=colnames(sml.matrix)[2],cex.main=0.85,cex.lab=0.75,cex.axis=0.75,main='Security Market Line \n (when CAPM holds)',type='lines',x=betas.raw,y=avg.fitted.ret,col='black',lwd=1.5) points(sml.matrix,type='p',col=col.ind,pch=20,cex=1.5) text(labels=1:num.assets,x=sml.matrix[,1],y=sml.matrix[,2],pos=3,col='blue',cex=0.65) points(x=1,tangency.sharpe.ret-risk.free,pch=8,col='red',cex=1.5) text(labels='MVE Portfolio\n(Market Portfolio)',x=1,y=tangency.sharpe.ret,pos=1,col='red',cex=0.65) legend(xpd=NA,xjust=0,title='Simulated Assets',"topleft",fill=c(col.ind),legend=c(paste('Asset:',1:num.assets)),bg='white',bty='n',border='white',cex=0.65) #Security Market Line if CAPM does not hold windows() par(oma=c(0,0,0,0)) sml.matrix <- matrix(dimnames=list(c(paste('Asset:',1:num.assets)),c('Beta','Expected Return')),c(in.betas,avg.ret.c),byrow=F,nrow=num.assets,ncol=2) plot(cex.main=0.85,cex.lab=0.75,cex.axis=0.75,main='Security Market Line \n (when CAPM does not hold)',type='lines',col='black',lwd=1.5,x=in.betas,y=avg.fitted.ret.c) points(sml.matrix,type='p',col=col.ind,pch=20,cex=1.5) text(labels=1:num.assets,x=sml.matrix[,1],y=sml.matrix[,2],pos=3,col='blue',cex=0.65) legend(xpd=NA,xjust=0,title='Simulated Assets',"topleft",fill=c(col.ind),legend=c(paste('Asset:',1:num.assets)),bg='white',bty='n',border='white',cex=0.65) }

d

################################################################################################### # # New Frontiers # ################################################################################################### CAPM.Frontiers <- function(type,orig.optimal.port,risky.assets,fitted.data,rand.ind){ risk.free <- risky.assets[[4]] num.assets <- ncol(risky.assets[[1]]) num.obs <- nrow(risky.assets[[1]]) shock <- (risky.assets[[6]][,rand.ind])*2 tangency.sharpe.ret <- orig.optimal.port[[4]][1]-risk.free tangency.sharpe.risk <- orig.optimal.port[[4]][2] tangency.sharpe.var <-tangency.sharpe.risk^2 tangency.ts <- fitted.data[[3]] col.ind <- rainbow(num.assets) if(type=='CAPM Prevails') { asset.ts <- risky.assets[[1]][,rand.ind] asset.ret <- mean(asset.ts) asset.risk <- sd(asset.ts) asset.var <- asset.risk^2 cov.est <- cov(asset.ts,tangency.ts) } else if(type=='CAPM Fails') { asset.ts <- risky.assets[[1]][,rand.ind]+shock asset.ret <- mean(asset.ts) asset.risk <- sd(asset.ts) asset.var <- asset.risk^2 cov.est <- cov(asset.ts,tangency.ts) } asset.weight <- seq(-1,1,length.out=100) port.weight <- 1- asset.weight new.frontier <- matrix(0,dimnames=list(c(paste('points:',1:100)),c('asset.weight','port.weight','expected.return','risk')),nrow=100,ncol=4) new.frontier[,1] <- asset.weight new.frontier[,2] <- port.weight new.frontier[,3] <- (asset.weight*asset.ret)+(port.weight*tangency.sharpe.ret) new.frontier[,4] <- sqrt((asset.weight^2)*asset.var+(port.weight^2)*tangency.sharpe.var+(2*cov.est*asset.weight*port.weight)) lines(x=new.frontier[,4],y=new.frontier[,3],type='lines',col=col.ind[rand.ind]) }

a

############################################################## # # Fitting the Model # ############################################################## Fitting.model <- function(risky.assets,frontier.points){ assets.ret <- risky.assets[[1]] assets.mean.ret <- risky.assets[[5]] risk.free <- risky.assets[[4]] num.assets <- ncol(assets.ret) num.obs <- nrow(assets.ret) tangency.sharpe.ret <- frontier.points[[4]][1] tangency.sharpe.risk <- frontier.points[[4]][2] tangency.weights <- as.matrix(frontier.points[[4]][-(1:3)]) #tangency.excess.ret <- rnorm(num.obs,tangency.sharpe.ret-risk.free,tangency.sharpe.risk) assets.excess.ret <- assets.ret - risk.free tangency.excess.ret <- (assets.excess.ret%*%tangency.weights) fitted.results <- lm(assets.excess.ret~tangency.excess.ret) return(list(fitted.results,tangency.sharpe.ret,tangency.excess.ret)) }

d

Again, we will simulate return/risk data for 25 assets, draw the CAL, the efficient frontier,locate the sharpe maximising portfolio on it, plot the indifference contours (just for the sake of completion). The security characteristics line,security market line along with various mean variance contours will be drawn and/or added.

k

sim.opt <- simulate.assets(25) sim.mvf <- MVF(sim.opt) cal.opt <- CAL.line('Sharpe',sim.opt,sim.mvf) DrawCAL(cal.opt,sim.opt,sim.mvf,legend.draw=TRUE) utility.contours('Sharpe',sim.opt,0.3,sim.mvf) DrawMVF(sim.mvf,FALSE,NULL,NULL) fit <- Fitting.model(sim.opt,sim.mvf) for(i in 1:25){ CAPM.Frontiers(type='CAPM Prevails',sim.mvf,sim.opt,fit,rand.ind=i) } #Draw Security Lines DrawSecurityLines(sim.opt,sim.mvf,fit)

j

**[Implications Of The CAPM ]**

As alluded to at the beginning of this post, we would like to explore some of the main implications on assets in a universe where the CAPM holds versus that where the CAPM as an equilibrium argument fails. Using a unique colour code for each of the 25 simulated assets, the following 3 plots show some of the main results that emerge when the CAPM is true. On an operational note, I should mention that the time series data associated with the tangency portfolio,a necessary input to subsequent implementations, was obtained from multiplying the optimal asset weights by their relevant risky asset returns at each point in time. I am not certain as to whether this approach to ‘reverse-engineer’ the time series return for the optimal portfolio is valid, but if it is, and judging from the regression results that ensue that this is the case, the time series returns thus obtained are consistent with the CAPM.

o

**:: Contours :**

As with any post found on this blog, **nothing** should be regarded as instructive or written up for the purposes of reproducible research. A loose diary of tinkering is a more apt description. As a case in point, this is what we would expect if the code was correct (copied from google images):

Although the main point (as far as I understand it) remains valid, my plots do look a bit different and I do not know whether this is due to the nature of the simulated data points or whether this is due to wrong code. In any case the following descriptions are based on the fact/lie/notion that the code is right.

The plot above charts the 25 simulated data points in the risk-return space, along with the **CAL (here the CML since we are looking at all investors)**,the mean variance frontier, the global minimum variance portfolio, the optimal risky portfolio as well as 25 additional frontiers, each of which connecting a risky asset with the original optimal risky portfolio. As loosely sketched above, one implication of the **CAPM** is that any combination of a risky asset and the tangency portfolio (market portfolio under the **CAPM**) must be efficient. In other words, if markets are in equilibrium, the marginal benefit to cost ratio across all assets/portfolios is identical, implying that investors have no incentive to change portfolio composition and ultimately that there is no scope to increase the sharpe ratio by combining that optimal portfolio with any risky asset. With reference to the figure above, since all combinations of a risky asset and the tangency portfolio (**coloured contours**) fall within the original (**black**) frontier in such a manner as to achieve tangency with the original **CML, **we cannot combine a risky asset with the optimal risky portfolio to increase the Sharpe-ratio. This can be visually confirmed by drawing a mental **CAL** (**CML**) between the risk free asset and any point on any coloured contour and noting that the current **CAL** (**CML**) still maintains the highest slope and hence maximal sharpe ratio.

To compare this with the case where the **CAPM** does not hold, let us ‘shock’ the asset returns by some random amount so that their marginal benefit to cost ratios diverge relative to the tangency portfolio and note the consequent effects on the same set of plots.

for(i in 1:25){ CAPM.Frontiers(type='CAPM Fails',sim.mvf,sim.opt,fit,rand.ind=i) }

We can see that the resulting coloured frontiers sometimes exceed the original **CAL** implying that a higher sharpe ratio could be achieved by combining a certain risky asset with the original tangency portfolio.

u

**:: Security Characteristic Lines:**

Another implication relating to the validity/failure of the **CAPM** that can be visually examined is captured in security characteristic lines which plot the excess asset returns of an asset against that of the market portfolio (tangency portfolio in our simulated case). In the case the **CAPM** **prevails**, we would expect the intercept from this time series regression to not be statistically different from 0. In other words we would fail to reject the null hypothesis that the intercept term is 0, concluding that the excess asset returns are related to excess market returns via beta.

Regressing excess asset returns on excess market returns when the **CAPM** holds yields the following p-values for coefficients. The green line denotes a **significance level of 0.10**. Since the p-value of alphas across assets are in excess of the significance level selected,we cannot reject the hypothesis that alpha is equal to zero for assets individually. Hence in subsequent implementations where **CAPM** is deemed to prevail, **alphas are set to 0**.

[

The Security Charactersitic Lines for the case where the CAPM prevail/fails is shown below. As illustrated above, if the CAPM holds, intercepts should be 0.

Shocking our **CAPM** consistent returns by a random amount and regressing these excess returns against the original tangency portfolio returns yields the following chart.

x

**:: Security Market Lines:**

Another visual difference between the case where the CAPM prevails/fails can be captured by Security Market Lines which are cross sectional regressions of average asset excess returns on the estimated betas in the previous time series regression.

If the CAPM holds, all assets are correctly prices and plot directly on the line. The market portfolio (tangency portfolio from simulated assets) has a beta of 1 as it covaries with itself.

Once we shock the **CAPM** consistent returns, assets become mispriced relative to their risk. Assets that plot above (below) the **SML** are commanding a return in excess of (less than) what they deserve and hence are undervalued (overvalued) by the market in terms of price. We would expect undervalued assets to be bought,pushing prices up and returns down until the **SML** is reached. Overvalued assets on the other hand are priced to highly by the market and will be sold in anticipation of future downward price reversions to the level predicted by the **SML**. Hence whenever assets are correctly priced in terms of their risk, an equilibrium state is reached in which investors have no incentive to take long/short positions.