\HeaderA{chart.BarVaR}{Periodic returns in a bar chart with risk metric overlay}{chart.BarVaR}
\keyword{ts}{chart.BarVaR}
\keyword{multivariate}{chart.BarVaR}
\keyword{distribution}{chart.BarVaR}
\keyword{models}{chart.BarVaR}
\keyword{hplot}{chart.BarVaR}
\begin{Description}\relax
Plots the periodic returns in a bar chart overlayed with a risk metric calculation.
\end{Description}
\begin{Usage}
\begin{verbatim}
chart.BarVaR(R, width = 0, gap = 12, methods = c("none", "ModifiedVaR", "GaussianVaR", "HistoricalVaR", "StdDev", "ModifiedES", "GaussianES", "HistoricalES"), clean = c("none", "boudt","geltner"),  ylim = NA, lwd = 2, colorset = 1:12, p=.95, 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, ...)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{R}] an xts, vector, matrix, data frame, timeSeries or zoo object of asset returns 
\item[\code{width}] periods specified for rolling-period calculations.  Note that VaR and Std Dev with width=0 are calculated from the start of the timeseries 
\item[\code{gap}] numeric number of periods from start of series to use to train risk calculation 
\item[\code{methods}] any of \emph{StdDev}, \emph{HistoricalVaR}, \emph{GaussianVaR}, or \emph{ModifiedVaR}, defaults to HistoricalVaR and ModifiedVaR 
\item[\code{p}] confidence level for \code{VaR} or \code{ModifiedVaR} calculation, default is .99 
\item[\code{ylim}] set the y-axis limit, same as in \code{\LinkA{plot}{plot}} 
\item[\code{lwd}] set the line width, same as in \code{\LinkA{plot}{plot}} 
\item[\code{lty}] set the line type, same as in \code{\LinkA{plot}{plot}} 
\item[\code{all}] if TRUE, calculates risk lines for each column given in R.  If FALSE, only calculates the risk line for the first column 
\item[\code{show.clean}] if TRUE and a method for 'clean' is specified, overlays the actual data with the "cleaned" data.  See \code{\LinkA{Return.clean}{Return.clean}} for more detail
\item[\code{clean}] the method to use to clean outliers from return data prior to risk metric estimation. See \code{\LinkA{Return.clean}{Return.clean}} and \code{\LinkA{VaR}{VaR}} for more detail 
\item[\code{show.horizontal}] if TRUE, shows a line across the timeseries at the value of the most recent VaR estimate, to help the reader evaluate the number of exceptions thus far 
\item[\code{show.symmetric}] if TRUE and the metric is symmetric, this will show the metric's positive values as well as negative values, such as for method "StdDev".
\item[\code{legend.loc}] legend location, such as in \code{\LinkA{chart.TimeSeries}{chart.TimeSeries}}
\item[\code{ypad}] adds a numerical padding to the y-axis to keep the data away when legend.loc="bottom".  See examples below.
\item[\code{legend.cex}] sets the legend text size, such as in \code{\LinkA{chart.TimeSeries}{chart.TimeSeries}}
\item[\code{colorset}] color palette to use, set by default to rational choices 
\item[\code{...}] any other passthru parameters to \code{\LinkA{chart.TimeSeries}{chart.TimeSeries}} 
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
Note that \code{StdDev} and \code{VaR} are symmetric calculations, so a high and low measure will be plotted.  \code{ModifiedVaR}, on the other hand, is assymetric and only a lower bound will be drawn.
\end{Details}
\begin{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.
\end{Value}
\begin{Author}\relax
Peter Carl
\end{Author}
\begin{SeeAlso}\relax
\code{\LinkA{chart.TimeSeries}{chart.TimeSeries}} \\
\code{\LinkA{plot}{plot}} \\
\code{\LinkA{VaR}{VaR}} \\
\code{\LinkA{VaR}{VaR}} \\
\code{\LinkA{Return.clean}{Return.clean}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
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")
\end{ExampleCode}
\end{Examples}

