# [Eventstudies-commits] r59 - pkg/vignettes

Mon Apr 29 16:23:37 CEST 2013

Author: vikram
Date: 2013-04-29 16:23:37 +0200 (Mon, 29 Apr 2013)
New Revision: 59

Modified:
pkg/vignettes/eventstudies.Rnw
pkg/vignettes/identifyextremeevent.Rnw
Log:
Wrote identify extreme events vignette

Modified: pkg/vignettes/eventstudies.Rnw
===================================================================
--- pkg/vignettes/eventstudies.Rnw	2013-04-29 11:55:53 UTC (rev 58)
+++ pkg/vignettes/eventstudies.Rnw	2013-04-29 14:23:37 UTC (rev 59)
@@ -20,10 +20,8 @@
The structure of the package and its implementation of event study
methodology is explained in this paper. In addition to converting
physical dates to event time frame, functions for re-indexing the
-event time returns, bootstrap inference estimation, and identification
-of extreme clustered events and further in-depth analysis of the
-same is also provided. The methods and functions are elucidated by
-employing data-set of SENSEX firms.
+event time returns and bootstrap inference estimation. The methods and
+functions are elucidated by employing data-set ofSENSEX firms.
\end{abstract}

\SweaveOpts{engine=R,pdf=TRUE}
@@ -106,14 +104,25 @@
Here, we index the stock split date, stock price returns to day 0 and
similarly post event dates are indexed to positive and pre event
dates are indexed as negative. As we can see below the stock split dates
-for BHEL, Bharti Airtel and Cipla are indexed to day 0.
+for BHEL, Bharti Airtel and Cipla are indexed to day 0.

-% outcomes, example
+The output for \textit{phys2eventtime} is a list. The first element of
+a list is a time series object which is converted to event
+time and the second element is \textit{outcomes} which shows if there
+was any \textit{NA} in the dataset. If the outcome is \textit{success}
+then all is well in the given window as specified by the
+width. It gives \textit{wdatamissing} if there are too many \textit{NAs} within the crucial event
+window or \textit{wrongspan} if the event date is not placed within
+the span of data for the unit or \textit{unitmissing} if a unit named
+in events is not in \textit{z}.

<<>>=
es <- phys2eventtime(z=StockPriceReturns, events=SplitDates, width=10)
es.w <- window(es$z.e, start=-10, end=10) SplitDates[1:3,] +StockPriceReturns[SplitDates[1,2],SplitDates[1,1]] +StockPriceReturns[SplitDates[2,2],SplitDates[2,1]] +StockPriceReturns[SplitDates[3,2],SplitDates[3,1]] es.w[,1:3] @ @@ -132,7 +141,7 @@ estimates like standard errors and confidence intervals. For this, we generate the sampling distribution for the estimate using bootstrap inference. A detailed explanation of the methodology is presented in -Shah, Patnaik and Singh (2013). +Patnaik, Shah and Singh (2013). This specific approach used here is based on Davinson, Hinkley and Schectman (1986). The \textit{inference.Ecar} function does the bootstrap to generate distribution of$\bar{CR}$. The bootstrap @@ -140,7 +149,7 @@ \begin{figure}[t] \begin{center} - \caption{Event on S\&P 500 and response of Nifty} + \caption{Stock splits event and response of respective stock returns} \setkeys{Gin}{width=0.8\linewidth} \setkeys{Gin}{height=0.8\linewidth} <<label=fig1,fig=TRUE,echo=FALSE>>= Modified: pkg/vignettes/identifyextremeevent.Rnw =================================================================== --- pkg/vignettes/identifyextremeevent.Rnw 2013-04-29 11:55:53 UTC (rev 58) +++ pkg/vignettes/identifyextremeevent.Rnw 2013-04-29 14:23:37 UTC (rev 59) @@ -8,7 +8,7 @@ \usepackage{tikz} \usepackage{parskip} \usepackage{amsmath} -\title{Introduction to the \textbf{eventstudies} package in R} +\title{Introduction to the \textbf{extreme events} functionality} \author{Ajay Shah, Vimal Balasubramaniam and Vikram Bahure} \begin{document} %\VignetteIndexEntry{eventstudies: A package with functionality to do Event Studies} @@ -17,57 +17,31 @@ %\VignettePackage{eventstudies} \maketitle \begin{abstract} -The structure of the package and its implementation of event study -methodology is explained in this paper. In addition to converting -physical dates to event time frame, functions for re-indexing the -event time returns, bootstrap inference estimation, and identification -of extreme clustered events and further in-depth analysis of the -same is also provided. The methods and functions are elucidated by -employing data-set for S\&P 500, Nifty and net Foreign Institutional -Investors (FII) flow in India. +The \textit{eventstudies} package also has extreme events +functionality. This package has \textit{identifyextremeevents} +function which does extreme event analysis by fusing the +consecutive extreme events in a single event. The methods and +functions are elucidated by employing data-set of S\&P 500 and Nifty. \end{abstract} \SweaveOpts{engine=R,pdf=TRUE} \section{Introduction} +The analysis done using this function is in tandem with Table 1,2,3,4 +and 5 of Patnaik, Shah and Singh (2013). A detail methodology is also +discussed in the paper mentioned. We use S\&P500 returns to +understand the \textit{identifyextremeevents} functionality. +Using this function, one can to understand the distribution and run +length of the clustered events, quantile values for the extreme +events and yearly distribution of the extreme events. -\section{Identify extreme events} -\subsection{Conceptual framework} -This function of the package identifies extreme event and does data -analysis. The upper tail and lower tail values are defined as extreme -events at certain probability. -There are two further issues to consider. First, matters are -complicated by the fact that extreme (tail) values may cluster: for -example, there may be two or three consecutive days of very high or -very low daily returns, or these extremes may occur in two out of -three days. If the extreme values are all in the same tail of the -distribution, it might make sense to consider the cluster of extreme -values as a single event. - -We approach this problem through two paths. The data has following -events: clustered, unclustered and mixed clusters. For simplicity, we -remove all the mixed clusters and deal with the rest. Unclustered or -uncontaminated events are those where there is no other event within -the event window. Clustered events are defined by fusing all -consecutive extreme events, of the same direction, into a single -event. In event time, date +1 is then the first day after the run of -extreme events, and date -1 is the last day prior to the start of the -run. This strategy avoids losing observations of some of the most -important crises, which have clustered extreme events in the same -direction. - -% Example for understanding -\subsection{Usage} -This function does extreme event analysis on the returns of the -data. Function has following two arguments: -\begin{enumerate} -\item \textit{input}: Data on which extreme event analysis is done. Note: - \textit{input} should be in returns format. -\item \textit{prob.value}: It is the tail value on basis of which the - extreme events are defined. For eg: \textit{prob.value} of 5 will consider - 5\% tail on both sides. -\end{enumerate} +\section{Extreme event analysis} +This function just needs input in returns format on which extreme +event analysis is to be done. Further we define tail events for given +probability value. For instance, if \textit{prob.value} is 5 then both +side 5\% tail events are considered as extreme, lower tail and upper +tail (5\% to 95\%). <<>>== library(eventstudies) data(identifyexeventData) @@ -75,8 +49,7 @@ output <- identifyextremeevents(input, prob.value=5) @ % I don't understand this output. Maybe you should explain what it means. -\subsection{Output} -Output is in list format. Primarily it consists of three lists, +The output is a list. Primarily it consists of three lists, summary statistics for complete data-set, extreme event analysis for lower tail and extreme event analysis for upper tail. Further, these lower tail and upper tail list objects consists of 5 more list objects with @@ -88,11 +61,8 @@ \item Quantile values of extreme events \item Yearly distribution of extreme events \end{enumerate} -The complete set of analysis is done on the returns of S\&P500 and -these results are in tandem with Table 1,2,3,4 and 5 of Patnaik, Shah -and Singh (2013). -\subsubsection{Summary statistics} +\subsection{Summary statistics} Here we have data summary for the complete data-set which shows minimum, 5\%, 25\%, median, mean, 75\%, 95\%, maximum, standard deviation (sd), inter-quartile range (IQR) and number of @@ -100,7 +70,7 @@ <<>>== output$data.summary
@
-\subsubsection{Extreme events dataset}
+\subsection{Extreme events dataset}
The output for upper tail and lower tail are in the same format as
mentioned above. The data-set is a time series object which has 2
columns. The first column is \textit{event.series} column which has
@@ -111,7 +81,7 @@
str(output$lower.tail$data)
@

-\subsubsection{Distribution of clustered and unclustered events}
+\subsection{Distribution of clustered and unclustered events}
In the analysis we have clustered, unclustered and mixed clusters. We
remove the mixed clusters and study the rest of the clusters by fusing
them. Here we show, number of clustered and unclustered data used in
@@ -125,7 +95,7 @@
output$lower.tail$extreme.event.distribution
@

-\subsubsection{Run length distribution of clusters}
+\subsection{Run length distribution of clusters}
Clusters used in the analysis are defined as consecutive extreme
events. Run length shows total number of clusters with \textit{n} consecutive
days. In the example below we have 3 clusters with  \textit{two}
@@ -135,14 +105,14 @@
output$lower.tail$runlength
@

-\subsubsection{Extreme event quantile values}
+\subsection{Extreme event quantile values}
Quantile values show 0\%, 25\%, median, 75\%,100\% and mean values for
the extreme events data.
<<>>=
output$lower.tail$quantile.values
@

-\subsubsection{Yearly distribution of extreme events}
+\subsection{Yearly distribution of extreme events}
This table shows the yearly distribution and
the median value for extreme events data.
<<>>=