\HeaderA{chart.Events}{Plots a time series with event dates aligned}{chart.Events}
\keyword{ts}{chart.Events}
\keyword{hplot}{chart.Events}
\begin{Description}\relax
Creates a time series plot where events given by a set of dates are aligned, with the adjacent prior and posterior time series data plotted in order.  The x-axis is time, but relative to the date specified, e.g., number of months preceeding or following the events.
\end{Description}
\begin{Usage}
\begin{verbatim}
chart.Events(R, dates, prior = 12, post = 12, main = NULL, xlab = NULL, ...)
\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{dates}] a list of dates (e.g., \code{c("09/03","05/06"))} formatted the same as in R.  This function matches the re-formatted row or index names (dates) with the given list, so to get a match the formatting needs to be correct. 
\item[\code{prior}] the number of periods to plot prior to the event.  Interpreted as a positive number.
\item[\code{post}] the number of periods to plot following to the event.  Interpreted as a positive number. 
\item[\code{main}] set the chart title, same as in \code{\LinkA{plot}{plot}} 
\item[\code{xlab}] set the x-axis label, same as in \code{\LinkA{plot}{plot}} 
\item[\code{...}] any other passthru parameters to the \code{\LinkA{plot}{plot}} function 
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
This is a chart that is commonly used for event studies in econometrics, usually with recession dates, to demonstrate the path of a time series going into and coming out of an event.  The time axis is simply the number of periods prior and following the event, and each line represents a different event.  Note that if time periods are close enough together and the window shown is wide enough, the data will appear to repeat.  That can be confusing, but the function does not currently allow for different windows around each event.
\end{Details}
\begin{Value}
Draws a timeseries plot of type "line" on a numbered x-axis, with a vertical dashed line indicating the alignment of the dates given.
\end{Value}
\begin{Author}\relax
Peter Carl
\end{Author}
\begin{SeeAlso}\relax
\code{\LinkA{chart.TimeSeries}{chart.TimeSeries}}, \code{\LinkA{plot}{plot}}, \code{\LinkA{par}{par}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
data(managers)
R = Drawdowns(managers[,2,drop=FALSE])
n = table.Drawdowns(managers[,2,drop=FALSE])                          
chart.Events(Drawdowns(managers[,2,drop=FALSE]), dates = n$Trough, prior=max(na.omit(n$"To Trough")), post=max(na.omit(n$Recovery)), lwd=2, colorset=redfocus, legend.loc=NULL, main = "Worst Drawdowns")
\end{ExampleCode}
\end{Examples}

