scatter chart of returns vs risk for comparing multiple instruments
A wrapper to create a scatter chart of annualized returns versus annualized risk (standard deviation) for comparing manager performance. Also puts a box plot into the margins to help identify the relative performance quartile.
chart.RiskReturnScatter(R, Rf = 0, main = "Annualized Return and Risk", add.names = TRUE, xlab = "Annualized Risk", ylab = "Annualized Return", method = "calc", geometric = TRUE, scale = NA, add.sharpe = c(1, 2, 3), add.boxplots = FALSE, colorset = 1, symbolset = 1, element.color = "darkgray", legend.loc = NULL, xlim = NULL, ylim = NULL, cex.legend = 1, cex.axis = 0.8, cex.main = 1, cex.lab = 1, ...)
- an xts, vector, matrix, data frame, timeSeries or zoo object of asset returns
- risk free rate, in same period as your returns
- number of periods in a year (daily scale = 252, monthly scale = 12, quarterly scale = 4)
- utilize geometric chaining (TRUE) or simple/arithmetic chaining (FALSE) to aggregate returns, default TRUE
- set the chart title, same as in
- plots the row name with the data point. default TRUE. Can be removed by setting it to NULL
- set the x-axis label, as in
- set the y-axis label, as in
- if set as "calc", then the function will calculate values from the set of returns passed in. If method is set to "nocalc" then we assume that R is a column of return and a column of risk (e.g., annualized returns, annualized risk), in that order.
- this draws a Sharpe ratio line that
indicates Sharpe ratio levels of
c(1,2,3). Lines are drawn with a y-intercept of the risk free rate and the slope of the appropriate Sharpe ratio level. Lines should be removed where not appropria
- TRUE/FALSE adds a boxplot summary of the data on the axis
- color palette to use, set by default to rational choices
plot, submit a set of symbols to be used in the same order as the data sets submitted
- provides the color for drawing chart elements, such as the box lines, axis lines, etc. Default is "darkgray"
- places a legend into one of nine locations on the chart: bottomright, bottom, bottomleft, left, topleft, top, topright, right, or center.
- set the x-axis limit, same as in
- set the y-axis limit, same as in
- The magnification to be used for axis
annotation relative to the current setting of 'cex', same
- The magnification to be used for sizing the legend relative to the current setting of 'cex'.
- The magnification to be used for sizing the title relative to the current setting of 'cex'.
- The magnification to be used for x and y labels relative to the current setting of 'cex'.
- any other passthru parameters to
Code inspired by a chart on:
data(edhec) chart.RiskReturnScatter(edhec, Rf = .04/12) chart.RiskReturnScatter(edhec, Rf = .04/12, add.boxplots = TRUE)