[Returnanalytics-commits] r3197 - in pkg/PortfolioAnalytics/sandbox/symposium2013: . docs

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Oct 2 21:46:18 CEST 2013


Author: peter_carl
Date: 2013-10-02 21:46:18 +0200 (Wed, 02 Oct 2013)
New Revision: 3197

Modified:
   pkg/PortfolioAnalytics/sandbox/symposium2013/analyze.HFindexes.R
   pkg/PortfolioAnalytics/sandbox/symposium2013/docs/symposium-slides-2013.Rmd
   pkg/PortfolioAnalytics/sandbox/symposium2013/optimize.HFindexes.R
   pkg/PortfolioAnalytics/sandbox/symposium2013/results.HFindexes.R
Log:
- new charts
- tweaks to old charts
- added HHI charts
- added hull to HHI

Modified: pkg/PortfolioAnalytics/sandbox/symposium2013/analyze.HFindexes.R
===================================================================
--- pkg/PortfolioAnalytics/sandbox/symposium2013/analyze.HFindexes.R	2013-09-30 18:42:44 UTC (rev 3196)
+++ pkg/PortfolioAnalytics/sandbox/symposium2013/analyze.HFindexes.R	2013-10-02 19:46:18 UTC (rev 3197)
@@ -58,6 +58,7 @@
 # Drop some indexes and reorder
 R = edhec[,c("Convertible Arbitrage", "Equity Market Neutral","Fixed Income Arbitrage", "Event Driven", "CTA Global", "Global Macro", "Long/Short Equity")]
 R.names = colnames(R)
+R.foldednames = sapply(colnames(R), function(x) paste(strwrap(x,10), collapse = "\n"), USE.NAMES=FALSE)
 
 ########################################################################
 # Returns-based performance analysis
@@ -79,15 +80,23 @@
 # --------------------------------------------------------------------
 # Monthly Returns and Risk
 # --------------------------------------------------------------------
-# @TODO: Too small: break this into two graphics? Directional, non-directional?
+# Done
 png(filename=paste(resultsdir, dataname, "-BarVaR.png", sep=""), units="in", height=5.5, width=9, res=96) 
 # Generate charts of returns with ETL and VaR through time
 par(mar=c(3, 4, 0, 2) + 0.1) #c(bottom, left, top, right)
-charts.BarVaR(R, p=p, gap=36, main="", show.greenredbars=TRUE, 
+charts.BarVaR(R[,1:4], p=p, gap=36, main="", show.greenredbars=TRUE, 
               methods=c("ModifiedES", "ModifiedVaR"), show.endvalue=TRUE, 
               colorset=rep("Black",7), ylim=c(-.1,.15))
 par(op)
 dev.off()
+png(filename=paste(resultsdir, dataname, "-BarVaR2.png", sep=""), units="in", height=5.5, width=9, res=96) 
+# Generate charts of returns with ETL and VaR through time
+par(mar=c(3, 4, 0, 2) + 0.1) #c(bottom, left, top, right)
+charts.BarVaR(R[,5:7], p=p, gap=36, main="", show.greenredbars=TRUE, 
+              methods=c("ModifiedES", "ModifiedVaR"), show.endvalue=TRUE, 
+              colorset=rep("Black",7), ylim=c(-.1,.15))
+par(op)
+dev.off()
 
 # --------------------------------------------------------------------
 # Rolling Performance
@@ -114,7 +123,7 @@
 # --------------------------------------------------------------------
 # @TODO: Too small, break into two panels?
 require(Hmisc)
-source(paste(functionsdir,'table.RiskStats.R', sep="")
+source(paste(functionsdir,'table.RiskStats.R', sep=""))
 incept.stats = t(table.RiskStats(R=R, p=p, Rf=Rf))
 write.csv(incept.stats, file=paste(resultsdir, dataname, "-inception-stats.csv", sep=""))
 png(filename=paste(resultsdir, dataname, "-InceptionStats.png", sep=""), units="in", height=5.5, width=9, res=96) 
@@ -124,12 +133,17 @@
 # --------------------------------------------------------------------
 # Compare Distributions
 # --------------------------------------------------------------------
-# @TODO: too small?
+# 
 png(filename=paste(resultsdir, dataname, "-Distributions.png", sep=""), units="in", height=5.5, width=9, res=96) 
-source(paste(functionsdir, "/page.Distributions", sep=""))
-page.Distributions(R)
+#source(paste(functionsdir, "/page.Distributions", sep=""))
+page.Distributions(R[,1:4])
 dev.off()
 
+png(filename=paste(resultsdir, dataname, "-Distributions2.png", sep=""), units="in", height=5.5, width=9, res=96) 
+#source(paste(functionsdir, "/page.Distributions", sep=""))
+page.Distributions(R[,5:7])
+dev.off()
+
 # --------------------------------------------------------------------
 # Correlation Panels
 # --------------------------------------------------------------------
@@ -161,7 +175,11 @@
 # --------------------------------------------------------------------
 
 write.csv(M, file=paste(resultsdir, dataname, "-inception-cor.csv", sep=""))
-
+  colnames(M)=R.foldednames
+# write(print(xtable(M, digits=1, align=rep("c",8)), type="html", html.table.attributes = "border = '0', align = 'center'"), file=paste(resultsdir, dataname, "-inception-cor.html", sep=""))
+# write(print(xtable(M, digits=1, align=rep("c",8))), file=paste(resultsdir, dataname, "-inception-cor.latex", sep=""))
+write(pandoc.table.return(M, digits=1, split.tables=Inf), file=paste(resultsdir, dataname, "-inception-cor.md", sep=""))
+  
 # --------------------------------------------------------------------
 # Rolling Correlation to S&P500 TR
 # --------------------------------------------------------------------

Modified: pkg/PortfolioAnalytics/sandbox/symposium2013/docs/symposium-slides-2013.Rmd
===================================================================
--- pkg/PortfolioAnalytics/sandbox/symposium2013/docs/symposium-slides-2013.Rmd	2013-09-30 18:42:44 UTC (rev 3196)
+++ pkg/PortfolioAnalytics/sandbox/symposium2013/docs/symposium-slides-2013.Rmd	2013-10-02 19:46:18 UTC (rev 3197)
@@ -2,6 +2,10 @@
 % Peter Carl, Hedge Fund Strategies, William Blair & Co.
 % November 11, 2013
 
+```{r}
+# R code here
+```
+
 <!---
 # TODO
  - Add a slide comparing traditional risk budgeting to equalized risk portfolios with limits
@@ -10,16 +14,14 @@
 <!---
 # HOWTO
 To create PDF of these slides:
-$ pandoc symposium-slides-2013.Rmd -t beamer -o slides.pdf
+$ pandoc symposium-slides-2013.Rmd -t beamer -o symposium-slides-2013.pdf
 
 This is an R Markdown document. Markdown is a simple formatting syntax for authoring web pages (click the **MD** toolbar button for help on Markdown).  Or see: http://daringfireball.net/projects/markdown/syntax
 
 When you click the **Knit HTML** button a web page will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
 
-```{r}
-summary(cars)
-```
 
+
 You can also embed plots, for example:
 
 ```{r fig.width=7, fig.height=6}
@@ -69,7 +71,7 @@
 * Convertible Arb
 * Equity Market Neutral
 * Event Driven
-
+***
 ## Directional
 
 * Equity Long/Short
@@ -85,6 +87,10 @@
 # Index Performance
 Add table of relevant statistics here
 
+```{r echo=FALSE}
+system('cat results/EDHEC-inception-cor.md')
+```
+
 # Ex-post Correlations
 \includegraphics[width=0.5\textwidth]{../results/EDHEC-cor-inception.png}
 \includegraphics[width=0.5\textwidth]{../results/EDHEC-cor-tr36m.png}
@@ -145,7 +151,7 @@
 \includegraphics[width=1.0\textwidth]{../results/EDHEC-Distributions.png}
 
 # Return distributions
-* Split chart into two for readability
+\includegraphics[width=1.0\textwidth]{../results/EDHEC-Distributions2.png}
 
 # Return autocorrelation
 \includegraphics[width=1.0\textwidth]{../results/EDHEC-ACStats.png}
@@ -171,11 +177,11 @@
 * ETL has all the properties a risk measure should have to be coherent and is a convex function of the portfolio weights
 * To account for skew and/or kurtosis, use Cornish-Fisher (or "modified") estimates of ETL instead (mETL)
 
-# Measuring risk
+# Measuring risk - directional strategies
 \includegraphics[width=1.0\textwidth]{../results/EDHEC-BarVaR.png}
 
-# Measuring risk
-Split graphic into two pages so it's readable
+# Measuring risk - non-directional strategies
+\includegraphics[width=1.0\textwidth]{../results/EDHEC-BarVaR2.png}
 
 # ETL sensitivity
 \includegraphics[width=1.0\textwidth]{../results/EDHEC-ETL-sensitivity.png}
@@ -392,31 +398,22 @@
 <!--- RESULTS -->
 
 # Sampled portfolios
-scatter chart with equal weight portfolio
+\includegraphics[width=1.0\textwidth]{../results/RP-EqWgt-MeanSD-ExAnte.png}
 
-# Turnover from equal-weight
-scatter chart colored by degree of turnover
-
 # Sampled portfolios
-add assets to scatter - overconstrained?
+\includegraphics[width=1.0\textwidth]{../results/RP-Assets-MeanSD-ExAnte.png}
 
-# Constrain by contribution to mETL
-Add a constraint
+# Sampled portfolios with multiple objectives
+\includegraphics[width=1.0\textwidth]{../results/RP-BUOY-MeanSD-ExAnte.png}
 
-# Ex-ante results
-scatter plot with multiple objectives
+# Modified ETL instead of volatility
+\includegraphics[width=1.0\textwidth]{../results/RP-BUOYS-mETL-ExAnte.png}
 
 # Ex-ante results
-scatter plot with multiple objectives, but in ETL space rather than variance
+\includegraphics[width=1.0\textwidth]{../results/Weights-Buoys.png}
 
-# Ex-ante results
-Unstacked bar chart comparing allocations across objectives
-
-# Out-of-sample results
-timeseries charts for cumulative return and drawdown
-
 # Risk contribution
-stacked bar chart of risk contribution through time (ex ante and ex post)
+\includegraphics[width=1.0\textwidth]{../results/mETL-CumulPerc-Contrib-Buoys.png}
 
 # Conclusions
 As a framework for strategic allocation:
@@ -510,5 +507,11 @@
 scatter plot with both overlaid
 
 
+# Turnover from equal-weight
+scatter chart colored by degree of turnover
+
+# Degree of Concentration
+scatter chart of RP colored by degree of concentration (HHI)
+
 # Scratch
 Slides likely to be deleted after this point
\ No newline at end of file

Modified: pkg/PortfolioAnalytics/sandbox/symposium2013/optimize.HFindexes.R
===================================================================
--- pkg/PortfolioAnalytics/sandbox/symposium2013/optimize.HFindexes.R	2013-09-30 18:42:44 UTC (rev 3196)
+++ pkg/PortfolioAnalytics/sandbox/symposium2013/optimize.HFindexes.R	2013-10-02 19:46:18 UTC (rev 3197)
@@ -21,7 +21,7 @@
 ### Set script constants
 runname='historical.moments'
 #rebalance_period = 'quarters' # uses endpoints identifiers from xts; how to do semi-annual?
-clean = "boudt" # "none" 
+clean = "none" #"boudt" # "none" 
 permutations = 2000
 p=1-1/12 # set confidence for VaR/mETL for monthly data
 
@@ -175,8 +175,8 @@
                                   multiplier=0, # calculate it but don't use it in the objective
                                   arguments=list(clean=clean)
 )
-EqmETL.portf$constraints[[1]]$min_sum = 0.99 # set to speed up RP
-EqmETL.portf$constraints[[1]]$max_sum = 1.01
+# EqmETL.portf$constraints[[1]]$min_sum = 0.99 # set to speed up RP
+# EqmETL.portf$constraints[[1]]$max_sum = 1.01
 
 ### Construct BUOY 7: Equal Weight Portfolio
 # There's only one, so create a portfolio object with all the objectives we want calculated. 
@@ -357,7 +357,7 @@
 RiskBudget.DE<-optimize.portfolio(R=R,
                                portfolio=RiskBudget.portf,
                                optimize_method='DEoptim',
-                              search_size=1000 #, trace=TRUE
+                              search_size=1000, trace=TRUE
                                ) 
 plot(RiskBudget.DE, risk.col="StdDev", return.col="mean")
 plot(RiskBudget.DE, risk.col="ES", return.col="mean") # several outlier portfolios

Modified: pkg/PortfolioAnalytics/sandbox/symposium2013/results.HFindexes.R
===================================================================
--- pkg/PortfolioAnalytics/sandbox/symposium2013/results.HFindexes.R	2013-09-30 18:42:44 UTC (rev 3196)
+++ pkg/PortfolioAnalytics/sandbox/symposium2013/results.HFindexes.R	2013-10-02 19:46:18 UTC (rev 3197)
@@ -6,7 +6,7 @@
 # Plot Ex Ante scatter of RP and ONLY Equal Weight portfolio in StdDev space
 # --------------------------------------------------------------------
 # Done
-png(filename="RP-EqWgt-MeanSD-ExAnte.png", units="in", height=5.5, width=9, res=96) 
+png(filename=paste(resultsdir, "RP-EqWgt-MeanSD-ExAnte.png", sep=""), units="in", height=5.5, width=9, res=96) 
 par(mar=c(5, 4, 1, 2) + 0.1) #c(bottom, left, top, right)
 # Calculate chart bounds to unify with the charts below
 xlim.StdDev=c(min(c(xtract[,"StdDev"], buoys.portfmeas[,"StdDev"])), max(c(xtract[,"StdDev"], buoys.portfmeas[,"StdDev"])))
@@ -28,7 +28,7 @@
 # Plot Ex Ante scatter of RP and ASSET portfolios in StdDev space
 # --------------------------------------------------------------------
 # @TODO: add the assets to this chart
-png(filename="RP-Assets-MeanSD-ExAnte.png", units="in", height=5.5, width=9, res=96) 
+png(filename=paste(resultsdir, "RP-Assets-MeanSD-ExAnte.png", sep=""), units="in", height=5.5, width=9, res=96) 
 xlim.StdDev.assets =c(min(c(xtract[,"StdDev"], assets.portfmeas[,"StdDev"], 0)), max(c(xtract[,"StdDev"], assets.portfmeas[,"StdDev"],0.03)))
 ylim.mean.assets =c(min(c(xtract[,"mean"], assets.portfmeas[,"Mean"], 0)), max(c(xtract[,"mean"], assets.portfmeas[,"Mean"])))
 par(mar=c(5, 4, 1, 2) + 0.1) #c(bottom, left, top, right)
@@ -53,7 +53,7 @@
 # Plot Ex Ante scatter of RP and BUOY portfolios in StdDev space
 # --------------------------------------------------------------------
 # Done
-png(filename="RP-BUOY-MeanSD-ExAnte.png", units="in", height=5.5, width=9, res=96) 
+png(filename=paste(resultsdir, "RP-BUOY-MeanSD-ExAnte.png", sep=""), units="in", height=5.5, width=9, res=96) 
 par(mar=c(5, 4, 1, 2) + 0.1) #c(bottom, left, top, right)
 plot(xtract[,"StdDev"],xtract[,"mean"], xlab="Ex Ante Std Dev", ylab="Ex Ante Mean", col="darkgray", axes=FALSE, main="", cex=.7, xlim=xlim.StdDev, ylim=ylim.mean)
 grid(col = "darkgray")
@@ -71,7 +71,7 @@
 # Plot Ex Ante scatter of RP and BUOY portfolios in mETL space
 # --------------------------------------------------------------------
 # Done
-png(filename="RP-BUOYS-mETL-ExAnte.png", units="in", height=5.5, width=9, res=96) 
+png(filename=paste(resultsdir, "RP-BUOYS-mETL-ExAnte.png", sep=""), units="in", height=5.5, width=9, res=96) 
 par(mar=c(5, 4, 1, 2) + 0.1) #c(bottom, left, top, right)
 xlim.ES=c(min(c(xtract[,"ES"], buoys.portfmeas[,"mETL"])), max(c(xtract[,"ES"], buoys.portfmeas[,"mETL"])))
 plot(xtract[,"ES"],xtract[,"mean"], xlab="Ex Ante mETL", ylab="Ex Ante Mean", col="darkgray", axes=FALSE, main="", cex=.7, xlim=xlim.ES, ylim=ylim.mean)
@@ -136,6 +136,14 @@
 par(op)
 dev.off()
 
+# --------------------------------------------------------------------
+# Scatter chart with DE trail
+# --------------------------------------------------------------------
+png(filename=paste(resultsdir, "DE-MeanSD-ExAnte.png", sep=""), units="in", height=5.5, width=9, res=96)
+# chart in same coordinates as RP; will leave some of the dots outside the chart bounds
+chart.RiskReward(RiskBudget.DE, risk.col="StdDev", return.col="mean", xlim=xlim.StdDev, ylim=ylim.mean)
+par(op)
+dev.off()
 
 # --------------------------------------------------------------------
 # Plot contribution of risk in EqWgt portfolio
@@ -274,6 +282,148 @@
 dev.off()
 
 # --------------------------------------------------------------------
-# Show CONCENTRATION of the RP portfolios?
+# Show CONCENTRATION of the RP portfolios
 # --------------------------------------------------------------------
-# Basically the same chart as above but use HHI instead of turnover calc
\ No newline at end of file
+# Basically the same chart as above but use HHI instead of turnover calc
+
+png(filename="ConcPercESContrib.png", units="in", height=5.5, width=9, res=96)
+WB20 = c(colorpanel(1, "#008566","#E1E56D"), colorpanel(20, "#E1E56D", "#742414")[-1])
+op <- par(no.readonly=TRUE)
+layout(matrix(c(1,2)),height=c(4,1.25),width=1)
+par(mar=c(4,4,1,2)+.1, cex=1) # c(bottom, left, top, right)
+## Draw the Scatter chart of combined results
+### Get the random portfolios from one of the result sets
+x.hhi=apply(xtract[,10:16], FUN='HHI', MARGIN=1)
+y=(x.hhi-min(x.hhi))/(max(x.hhi)-min(x.hhi)) # normalized HHI between 0 and 1
+plot(xtract[order(y,decreasing=TRUE),"StdDev"],xtract[order(y,decreasing=TRUE),"mean"], xlab="Ex Ante StdDev", ylab="Ex Ante Mean", col=WB20[floor(y[order(y,decreasing=TRUE)]*19)+1], axes=FALSE, main="", cex=.7, pch=16)
+grid(col = "darkgray")
+# points(RND.objectives[1,2],RND.objectives[1,1], col="blue", pch=19, cex=1.5)
+axis(1, cex.axis = 0.8, col = "darkgray")
+axis(2, cex.axis = 0.8, col = "darkgray")
+box(col = "darkgray")
+
+# Add legend to bottom panel
+par(mar=c(5,5.5,1,3)+.1, cex=0.7)
+## Create a histogramed legend for sequential colorsets
+## this next bit of code is based on heatmap.2 in gplots package
+x=x.hhi
+scale01 <- function(x, low = min(x), high = max(x)) {
+  return((x - low)/(high - low))
+}
+breaks <- seq(min(x, na.rm = TRUE), max(x, na.rm = TRUE), length = length(WB20)+1)
+min.raw <- min(x, na.rm = TRUE)
+max.raw <- max(x, na.rm = TRUE)
+z <- seq(min.raw, max.raw, length = length(WB20))
+image(z = matrix(z, ncol = 1), col = WB20, breaks = breaks, xaxt = "n", yaxt = "n")
+par(usr = c(0, 1, 0, 1)) # needed to draw the histogram correctly
+lv <- pretty(breaks)
+xv <- scale01(as.numeric(lv), min.raw, max.raw)
+axis(1, at = xv, labels=sprintf("%s%%", pretty(lv)))
+h <- hist(x, plot = FALSE, breaks=breaks)
+hx <- scale01(breaks, min(x), max(x))
+hy <- c(h$counts, h$counts[length(h$counts)])
+lines(hx, hy/max(hy)*.95, lwd = 2, type = "s", col = "blue")
+axis(2, at = pretty(hy)/max(hy)*.95, pretty(hy))
+title(ylab="Count")
+title(xlab="Degree of Concentration from Equal Contribution Portfolio")
+par(op)
+dev.off()
+
+# --------------------------------------------------------------------
+# Show CONCENTRATION of the RP portfolios in HHI space
+# --------------------------------------------------------------------
+png(filename="ConcPercESContrib-HHI-wHull.png", units="in", height=5.5, width=9, res=96)
+WB20 = c(colorpanel(1, "#008566","#E1E56D"), colorpanel(20, "#E1E56D", "#742414")[-1])
+op <- par(no.readonly=TRUE)
+layout(matrix(c(1,2)),height=c(4,1.25),width=1)
+par(mar=c(4,4,1,2)+.1, cex=1) # c(bottom, left, top, right)
+seq.col = heat.colors(11)
+## Draw the Scatter chart of combined results
+### Get the random portfolios from one of the result sets
+x.hhi=apply(xtract[,10:16], FUN='HHI', MARGIN=1)
+y=(x.hhi-min(x.hhi))/(max(x.hhi)-min(x.hhi)) # normalized HHI between 0 and 1
+plot(x.hhi[order(y,decreasing=TRUE)],xtract[order(y,decreasing=TRUE),"mean"], xlab="Degree of ex ante Risk Contribution", ylab="Ex Ante Mean", col=WB20[floor(y[order(y,decreasing=TRUE)]*19)+1], axes=FALSE, main="", cex=.7, pch=16)
+grid(col = "darkgray")
+# points(RND.objectives[1,2],RND.objectives[1,1], col="blue", pch=19, cex=1.5)
+axis(1, cex.axis = 0.8, col = "darkgray")
+axis(2, cex.axis = 0.8, col = "darkgray")
+box(col = "darkgray")
+
+# HOWTO add a hull to this diagram
+# Make a data.frame out of your vectors
+dat <- data.frame(X = x.hhi[order(y,decreasing=TRUE)], Y = xtract[order(y,decreasing=TRUE),"mean"])
+dat <- data.frame(X = x.hhi, Y = xtract[,"mean"])
+# Compute the convex hull. This returns the index for the X and Y coordinates
+c.hull <- chull(dat)
+#Extract the coordinate points from the convex hull with the index.
+z=dat[c.hull,]
+# Plot the full hull
+# with(dat, plot(X,Y))
+# lines(z, col = "pink", lwd = 3)
+
+# Or just do the ascending hull in Y
+z[,3] <- c(diff(as.numeric(z[,1])),z[1,1]-tail(z[,1],1)) # calculate whether the line segment is ascending in X
+z[,4] <- c(tail(z[,2],1)-z[1,2],diff(as.numeric(z[,2]))) # calculate whether the line segment is ascending in Y
+lines(z[z[,3]>0 & z[,4]>0,1:2], col = "darkgrey", lwd = 2, type="b")
+z=cbind(z,c.hull)
+# Here are the portfolios on the hull
+hull.portfolios=z[which(z[,3]>0 & z[,4]>0),5]
+
+# Add legend to bottom panel
+par(mar=c(5,5.5,1,3)+.1, cex=0.7)
+## Create a histogramed legend for sequential colorsets
+## this next bit of code is based on heatmap.2 in gplots package
+x=x.hhi
+scale01 <- function(x, low = min(x), high = max(x)) {
+  return((x - low)/(high - low))
+}
+breaks <- seq(min(x, na.rm = TRUE), max(x, na.rm = TRUE), length = length(WB20)+1)
+min.raw <- min(x, na.rm = TRUE)
+max.raw <- max(x, na.rm = TRUE)
+z <- seq(min.raw, max.raw, length = length(WB20))
+image(z = matrix(z, ncol = 1), col = WB20, breaks = breaks, xaxt = "n", yaxt = "n")
+par(usr = c(0, 1, 0, 1)) # needed to draw the histogram correctly
+lv <- pretty(breaks)
+xv <- scale01(as.numeric(lv), min.raw, max.raw)
+axis(1, at = xv, labels=sprintf("%s%%", pretty(lv)))
+h <- hist(x, plot = FALSE, breaks=breaks)
+hx <- scale01(breaks, min(x), max(x))
+hy <- c(h$counts, h$counts[length(h$counts)])
+lines(hx, hy/max(hy)*.95, lwd = 2, type = "s", col = "blue")
+axis(2, at = pretty(hy)/max(hy)*.95, pretty(hy))
+title(ylab="Count")
+title(xlab="Degree of Concentration from Equal Contribution Portfolio")
+par(op)
+dev.off()
+
+
+
+# Again, in Std Dev space with hull outlined
+png(filename="ConcPercESContrib-SD-wHull.png", units="in", height=5.5, width=9, res=96)
+WB20 = c(colorpanel(1, "#008566","#E1E56D"), colorpanel(20, "#E1E56D", "#742414")[-1])
+op <- par(no.readonly=TRUE)
+layout(matrix(c(1,2)),height=c(4,1.25),width=1)
+par(mar=c(4,4,1,2)+.1, cex=1) # c(bottom, left, top, right)
+plot(xtract[order(y,decreasing=TRUE),"StdDev"],xtract[order(y,decreasing=TRUE),"mean"], xlab="Ex Ante StdDev", ylab="Ex Ante Mean", col=WB20[floor(y[order(y,decreasing=TRUE)]*19)+1], axes=FALSE, main="", cex=.7, pch=16)
+points(xtract[hull.portfolios,"StdDev"], xtract[hull.portfolios,"mean"], col='blue')
+lines(xtract[hull.portfolios,"StdDev"], xtract[hull.portfolios,"mean"], type="b", col='blue')
+grid(col = "darkgray")
+axis(1, cex.axis = 0.8, col = "darkgray")
+axis(2, cex.axis = 0.8, col = "darkgray")
+box(col = "darkgray")
+dev.off()
+
+# Again, in ES space with hull outlined
+png(filename="ConcPercESContrib-mETL-wHull.png", units="in", height=5.5, width=9, res=96)
+WB20 = c(colorpanel(1, "#008566","#E1E56D"), colorpanel(20, "#E1E56D", "#742414")[-1])
+op <- par(no.readonly=TRUE)
+layout(matrix(c(1,2)),height=c(4,1.25),width=1)
+par(mar=c(4,4,1,2)+.1, cex=1) # c(bottom, left, top, right)
+plot(xtract[order(y,decreasing=TRUE),"ES"],xtract[order(y,decreasing=TRUE),"mean"], xlab="Ex Ante mETL", ylab="Ex Ante Mean", col=WB20[floor(y[order(y,decreasing=TRUE)]*19)+1], axes=FALSE, main="", cex=.7, pch=16)
+points(xtract[hull.portfolios,"ES"], xtract[hull.portfolios,"mean"], col='blue')
+lines(xtract[hull.portfolios,"ES"], xtract[hull.portfolios,"mean"], type="b", col='blue')
+grid(col = "darkgray")
+axis(1, cex.axis = 0.8, col = "darkgray")
+axis(2, cex.axis = 0.8, col = "darkgray")
+box(col = "darkgray")
+dev.off()
\ No newline at end of file



More information about the Returnanalytics-commits mailing list