Learn R Programming

PerformanceAnalytics (version 0.9.5)

chart.RelativePerformance: relative performance chart between multiple return series

Description

A wrapper to create a chart of relative returns through time

Usage

chart.RelativePerformance(Ra, Rb, main = "Relative Performance", xaxis = TRUE, colorset = (1:12), legend.loc = NULL, ylog = FALSE, ...)

Arguments

Ra
a vector, matrix, data frame, timeSeries or zoo object of asset returns
Rb
return vector of the benchmark asset
main
set the chart title, same as in plot
xaxis
if true, draws the x axis
colorset
color palette to use, set by default to rational choices
legend.loc
places a legend into one of nine locations on the chart: bottomright, bottom, bottomleft, left, topleft, top, topright, right, or center.
ylog
TRUE/FALSE set the y-axis to logarithmic scale, similar to plot, default FALSE
...
any other passthru parameters

Value

  • chart of relative returns

Examples

Run this code
# First we get the data
data(edhec)
edhec.length = dim(edhec)[1]
start = rownames(edhec[1,])
start
end = rownames(edhec[edhec.length,])

edhec.zoo = zoo(edhec, order.by = rownames(edhec))
sp500.zoo = download.SP500PriceReturns(start = "1996-12-31", end = end)

# Then align the dates as "monthly" data
time(edhec.zoo) = as.yearmon(time(edhec.zoo))
time(sp500.zoo) = as.yearmon(time(sp500.zoo))
data.zoo = merge(edhec.zoo[,9,drop=FALSE],sp500.zoo)
time(data.zoo) = as.Date(time(data.zoo),format="%b %Y")

# Finally, plot it
chart.RelativePerformance(data.zoo[, 1, drop=FALSE], data.zoo[, 2, drop=FALSE], colorset=rich8equal, legend.loc="bottomright", lwd=2)

Run the code above in your browser using DataLab