Archive

Tag Archives: barplots

To arbitrarily round off this series of posts, along which a sketch of the traditional asset pricing framework has been attempted,  a dashboard of simple plots shall be made to summarise some of the implications of extending the 2-asset base case with an additional risky asset. Starting with the base case of 2 risky assets and one riskless asset, we shall once again draw the minimum variance frontier as well as the capital allocation line to locate the tangency portfolio. A pie chart will conveniently summarise the tangency portfolio weights associated with these 2 assets. The base case with two risky assets will then be extended by including additional risky assets, one at a time , holding the variance of each asset’s return constant while varying the mean return of that asset. Assets will be added sequentially to the base case, so that at any time only 3 risky assets are in the universe along with one riskless asset. Barcharts will illustrate the returns and risks on tangency portfolios for each of the extended scenarios. An area chart will summarise how asset weights vary in tangency portfolios across scenarios.

###################################################################################################
###################################################################################################
#Supplement 2
###################################################################################################
###################################################################################################</pre>
idx <- seq(from=-0.5,to=0.2,length.out=10)
weights.mat <-ret.mat <- var.mat <- NULL
col <- adjustcolor(col=c('dark green','green','light green'),alpha.f=0.5)
front.col <- rainbow(length(idx))

#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

base<-Frontiers(two.asset.data)

windows()
 layout(matrix(c(1,1,1,2,1,1,1,3,1,1,1,4,5,5,5,5),4,4,byrow=T),height=c(0.20,0.20,0.2,0.3))
 par(mai=c(0.7,0.7,0.3,0.2))
 Frontier.Draw(two.asset.data,base,'red','new',lty=1,'Base Case\nextended with new asset')
 CAL.Draw(two.asset.data,base,'red',lty=1,tit=0)
 legend('bottom',fill=front.col,legend=round(idx,3),ncol=5,bg='white',bty='n',cex=0.9,title='New asset (with mean defined relative to base portfolio returns)')
 legend('topleft',legend=c('Tangency portfolios','Assets'),pch=c(17,16),bg='white',bty='o',cex=0.9,ncol=1)
 abline(h=-0.065)
 abline(h=-0.12)

for(i in 1:length(idx))
 {
 z.data <- list()
 z.data$mean.ret <- matrix(c(0.800,0.0500,0.8+idx[i]),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.02),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

 front<-Frontiers(z.data)
 Frontier.Draw(z.data,front,col=front.col[i],'add',2,legend=1)
 CAL.Draw(z.data,front,col=front.col[i],lty=1,tit=0)

weights.mat <- cbind(weights.mat,front$tang.weights)
 ret.mat <- cbind(ret.mat,front$tang.ret)
 var.mat <- cbind(var.mat,front$tang.risk)
 }

rownames(weights.mat) <- c('Asset 1','Asset 2','Asset 3')
 colnames(ret.mat) <- round(idx,2)
 colnames(var.mat) <-round(idx,2)
 weights.mat <- t(weights.mat)
 base.weights <- base$tang.weights

ret.mat <- matrix(ret.mat)
 var.mat <- matrix(var.mat)

par(mai=c(0.3,0.3,0.3,0.3))
 pie(cex.main=0.75,main='Base case\ntangency weights',base.weights,col=col[1:2],labels=c(paste('Asset 1\n',base.weights[1]*100,'%'),paste('Asset 2\n',base.weights[2]*100,'%')),cex=0.75,radius=0.85)

par(mai=c(0.5,0.3,0.3,0.3))
 barplot(axes=T,beside=T,horiz=F,ret.mat,cex.axis=0.75,cex.lab=0.75,cex.main=0.75,main='Tangency\nPortfolio Returns',col=front.col,xaxlab=c(1:10))

 par(mai=c(0.7,0.3,0.2,0.3))
 barplot(axes=T,beside=T,horiz=F,var.mat,cex.axis=0.75,cex.lab=0.75,cex.main=0.75,main='Tangency\nPortfolio Risk',col=front.col,xlab='Assets')

par(mai=c(0.7,0.7,0,0.3))
 stackpoly(xlim=c(1,length(idx)+1.5),axis4=F,cex.main=0.85,cex.lab=0.75,cex.axis=0.75,weights.mat,xaxlab=round(idx,2),border='white',stack=F,xlab='Deviations from base',ylab='Weights',lwd=1,col=col)
 legend('right',fill=col,legend=colnames(weights.mat),ncol=1,bg='white',bty='n',cex=0.85,title='Tangency\nPortfolio Weights')

The resulting dashboard of plots follows.

gg

The vertical alignment of the new assets implies that we are varying the mean returns while keeping their risk constant. Each of the minimum variance frontiers and capital allocation lines are drawn for 3 risky assets and one riskless asset. The mean return of each new asset is chosen as a deviation from the mean return of the second risky asset (Asset 2) of the base case scenario. The inputs associated with the assets in the base case scenario remain unchanged throughout. By varying only the mean returns of the additional risky assets and holding constant all other factors across the 10 scenarios, we can examine how optimal asset weights evolve according to return deviations. In the context of the base case scenario, the optimal risky portfolio would be 93.6% invested in asset 1 and 6.4% invested in asset 2. This is intuitive given that asset 1 has a mean return of 0.8 and a risk of 0.0256 while asset 2 enjoys a mean return of 0.05 and a lower risk of 0.0144. Evidently the lower risk of asset 2 does not sufficiently compensate for the small return it generates relative to asset 1 (0.05 vs 0.80). Visually this is corroborated by the proximity of the optimal risky portfolio relative to asset 1 on the MVF spanning the 2 risky assets in the frontier plot. Every time we add a new risky asset to the scenario, we ensure that it has a lower negative deviation or a higher positive deviation from asset 2’s mean return ( essentially from -0.5 to +0.2 relative to the second asset’s mean return). The risk of each and every one of those assets lies between those of the base assets (as evinced from the frontier plot). The barplots confirm the intuition that by adding risky assets with increasingly higher mean returns to the base case scenario, the return on the tangency portfolio increases. Similarly, as we reduce the negative deviations/enhance the positive deviations of the third asset’s mean return relative to the return of the base asset, the optimal weight shifts from base assets to asset 3.

In the previous post we visualised the quarterly returns for the 30 components of the DJIA between 2005-2009. After ranking quarterly performance of each stock , we proceeded to regress excess monthly log returns on the Fama & French factors in both the standard OLS and the more robust QRS frameworks. This post will focus on applying an input- oriented -variable- returns- to- scale DEA model to requisite inputs and outputs for each stock. While the regression coefficients extracted from the OLS and QRS procedures for each year constitute the inputs to the DEA model, the annualised returns for each stock represent associated outputs for each DMU. Before these attributes can be passed to the DEA model, it is first necessary to standardise and rescale them. The methodology is detailed in the links provided in the previous post.

l

windows()
    par(mai=c(0.1,0.5,0.5,0.5),mfrow=c(6,1))
    barplot(main="DEA applied to Quantile inputs",cex.names=0.9,horiz=F,cex.axis=0.9,beside=F,eff.05[,1],col=ifelse(round(t(eff.05[,1])[1,],2)<1.00,"red","blue"),las=2,xaxt='n')
    mtext(side=4,Years[1],cex=0.7)
    barplot(cex.names=0.9,horiz=F,cex.axis=0.9,beside=F,eff.06[,1],col=ifelse(round(t(eff.06[,1])[1,],2)<1.00,"red","blue"),las=2,xaxt='n')
    mtext(side=4,Years[2],cex=0.7)
    barplot(cex.names=0.9,horiz=F,cex.axis=0.9,beside=F,eff.07[,1],col=ifelse(round(t(eff.07[,1])[1,],2)<1.00,"red","blue"),las=2,xaxt='n')
    mtext(side=4,Years[3],cex=0.7)
    barplot(cex.names=0.9,horiz=F,cex.axis=0.9,beside=F,eff.08[,1],col=ifelse(round(t(eff.08[,1])[1,],2)<1.00,"red","blue"),las=2,xaxt='n')
    mtext(side=4,Years[4],cex=0.7)
    barplot(cex.names=0.9,horiz=F,cex.axis=0.9,beside=F,eff.09[,1],col=ifelse(round(t(eff.09[,1])[1,],2)<1.00,"red","blue"),las=2)
    mtext(side=4,Years[5],cex=0.7)
    plot.new()
    legend("center",title="Data Envelopement Analysis",fill=c("blue","red"),legend=c("Efficient","Inefficient"),ncol=2)

windows()
    par(mai=c(0.1,0.5,0.5,0.5),mfrow=c(6,1))
    barplot(main="DEA applied to OLS inputs",cex.names=0.9,horiz=F,cex.axis=0.9,beside=F,eff.ols.05[,1],col=ifelse(round(t(eff.ols.05[,1])[1,],2)<1.00,"red","blue"),las=2,xaxt='n')
    mtext(side=4,Years[1],cex=0.7)
    barplot(cex.names=0.9,horiz=F,cex.axis=0.9,beside=F,eff.ols.06[,1],col=ifelse(round(t(eff.ols.06[,1])[1,],2)<1.00,"red","blue"),las=2,xaxt='n')
    mtext(side=4,Years[2],cex=0.7)
    barplot(cex.names=0.9,horiz=F,cex.axis=0.9,beside=F,eff.ols.07[,1],col=ifelse(round(t(eff.ols.07[,1])[1,],2)<1.00,"red","blue"),las=2,xaxt='n')
    mtext(side=4,Years[3],cex=0.7)
    barplot(cex.names=0.9,horiz=F,cex.axis=0.9,beside=F,eff.ols.08[,1],col=ifelse(round(t(eff.ols.08[,1])[1,],2)<1.00,"red","blue"),las=2,xaxt='n')
    mtext(side=4,Years[4],cex=0.7)
    barplot(cex.names=0.9,horiz=F,cex.axis=0.9,beside=F,eff.ols.09[,1],col=ifelse(round(t(eff.ols.09[,1])[1,],2)<1.00,"red","blue"),las=2)
    mtext(side=4,Years[5],cex=0.7)
    plot.new()
        legend("center",title="Data Envelopement Analysis",fill=c("blue","red"),legend=c("Efficient","Inefficient"),ncol=2)


c

The collection of bar-plots above summarises the efficiency scores for each asset in each of the 5 years of data. In this case we are using OLS derived Fama and French coefficients as inputs to the DEA model for each stock. While the blue bars correspond to efficient stocks, the red bars represent inefficient DMUs.

o

f

The second collection of bar-plots above summarises the efficiency scores for each asset in each of the 5 years of data. In this case we are using QRS derived Fama and French coefficients as inputs to the DEA model for each stock. While the blue bars correspond to efficient stocks, the red bars represent inefficient DMUs. Now that we have determined the subset of the 30 index components that can be deemed efficient in each year using different inputs, let’s construct equally weighted portfolios of these efficient stocks for each year and input set and compare performance. Based on QRS inputs and DEA results, the portfolio constructed in 2009 for example is equally weighted across AXP,IBM,INTL,JNJ, KFT,MSFT,PFE,PG,UTX.

Above is a collection of stacked polygon plots that compares the monthly returns for OLS derived (darkblue) vs QRS derived(cyan) portfolios for 4 years (2006-2009). With the exception of a handful of months in each year, the OLS derived coefficients appear to create superior portfolio returns that the QRS derived counterparts. Only in 2008 , does the QRS portfolio appear to provide some consistency in the benefits of applying a more robust method to the data. As the table below shows,annualising portfolio returns does not seem to help much either. Contrary to expectations the OLS derived portfolio actually is better than the QRS counterpart. The only exception is in 2007-2008 where the QRS portfolio generates less negative returns than the OLS counterpart.

Quantile OLS
2006 15.770552 16.315416
2007 2.443413 3.332335
2008 -31.224554 -35.138542
2009 15.439622 27.783856

f
While the number range is somewhat comparable to those found in the study (link in previous post), we don’t replicate the superiority of QRS portfolios here. The discrepancy is probably due to my mistakes somewhere in the convoluted code. Non the less, it should be noted that the study used the 2005 DJIA components while I used the current index composition. Instead of CISCO and Traveller’s companies, the study had GM and CITI.