Learn R Programming

PerformanceAnalytics (version 0.9.7.1)

chart.BarVaR: Periodic returns in a bar chart with risk metric overlay

Description

Plots the periodic returns in a bar chart overlayed with a risk metric calculation.

Usage

chart.BarVaR(R, width = 0, gap = 12, methods = c("none", "ModifiedVaR","GaussianVaR","HistoricalVaR", "StdDev"), clean = c("none", "boudt"), reference.grid = TRUE, xaxis = TRUE, main = "Title", ylab="Value", xlab="Date", date.format = "%m/%y", xlim = NA, ylim = NA, lwd = 1, colorset = 1:12, p=.99, lty = c(1,2,4,5,6), all = FALSE, show.clean = FALSE, show.horizontal = FALSE, show.symmetric = FALSE, legend.loc="bottomleft", ypad=0, legend.cex = 0.8, ...)

Arguments

R
a vector, matrix, data frame, timeSeries or zoo object of asset returns
width
periods specified for rolling-period calculations. Note that VaR and Std Dev with width=0 are calculated from the start of the timeseries
gap
numeric number of periods from start of series to use to train risk calculation
methods
any of StdDev, HistoricalVaR, GaussianVaR, or ModifiedVaR, defaults to HistoricalVaR and ModifiedVaR
p
confidence level for VaR or ModifiedVaR calculation, default is .99
reference.grid
if true, draws a grid aligned with the points on the x and y axes
xaxis
if true, draws the x axis
main
set the chart title, same as in plot
ylab
set the y-axis label, same as in plot
xlab
set the x-axis label, same as in plot
date.format
re-format the dates for the xaxis; the default is "%m/%y"
xlim
set the x-axis limit, same as in plot
ylim
set the y-axis limit, same as in plot
lwd
set the line width, same as in plot
lty
set the line type, same as in plot
all
if TRUE, calculates risk lines for each column given in R. If FALSE, only calculates the risk line for the first column
show.clean
clean
show.horizontal
show.symmetric
legend.loc
ypad
legend.cex
colorset
color palette to use, set by default to rational choices
...
any other passthru parameters

Value

  • Creates a plot of time on the x-axis and vertical lines for each period to indicate value on the y-axis. Overlays a line to indicate the value of a risk metric calculated at that time period.

Details

Note that StdDev and VaR are symmetric calculations, so a high and low measure will be plotted. ModifiedVaR, on the other hand, is assymetric and only a lower bound will be drawn.

See Also

chart.TimeSeries plot VaR VaR.CornishFisher Return.clean

Examples

Run this code
data(managers)
# plain
chart.BarVaR(managers[,1,drop=FALSE], main="Monthly Returns")

# with risk line
chart.BarVaR(managers[,1,drop=FALSE], methods="HistoricalVaR", main="... with Empirical VaR from Inception")

# with lines for all managers in the sample
chart.BarVaR(managers[,1:6], methods="GaussianVaR", all=TRUE, lty=1, lwd=2, colorset= c("red", rep("gray", 5)), main="... with Gaussian VaR and Estimates for Peers")

# with multiple methods
chart.BarVaR(managers[,1,drop=FALSE],methods=c("HistoricalVaR", "ModifiedVaR", "GaussianVaR"), main="... with Multiple Methods")

# cleaned up a bit
chart.BarVaR(managers[,1,drop=FALSE],methods=c("HistoricalVaR", "ModifiedVaR", "GaussianVaR"), lwd=2, ypad=.01, main="... with Padding for Bottom Legend")

# with 'cleaned' data for VaR estimates
chart.BarVaR(managers[,1,drop=FALSE],methods=c("HistoricalVaR", "ModifiedVaR"), lwd=2, ypad=.01, clean="boudt", main="... with Robust ModVaR Estimate")

# Cornish Fisher VaR estimated with cleaned data, with horizontal line to show exceptions
chart.BarVaR(managers[,1,drop=FALSE],methods="ModifiedVaR", lwd=2, ypad=.01, clean="boudt", show.horizontal=TRUE, lty=2, main="... with Robust ModVaR and Line for Identifying Exceptions")

Run the code above in your browser using DataLab