[Eventstudies-commits] r39 - in pkg: . inst/doc vignettes

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Feb 11 18:15:42 CET 2013


Author: chiraganand
Date: 2013-02-11 18:15:41 +0100 (Mon, 11 Feb 2013)
New Revision: 39

Added:
   pkg/vignettes/
   pkg/vignettes/eventstudies.Rnw
Removed:
   pkg/inst/doc/eventstudies.Rnw
Log:
Moved package vignette to vignettes directory as inst/doc is now deprecated.


Deleted: pkg/inst/doc/eventstudies.Rnw
===================================================================
--- pkg/inst/doc/eventstudies.Rnw	2013-02-11 17:07:18 UTC (rev 38)
+++ pkg/inst/doc/eventstudies.Rnw	2013-02-11 17:15:41 UTC (rev 39)
@@ -1,198 +0,0 @@
-\documentclass[a4paper,11pt]{article}
-\usepackage{graphicx}
-\usepackage{a4wide}
-\usepackage[colorlinks,linkcolor=blue,citecolor=red]{hyperref}
-\usepackage{natbib}
-\usepackage{float}
-\title{Introduction to the \textbf{eventstudies} package in R}
-\author{}
-\begin{document}
-%\VignetteIndexEntry{eventstudies: A package with functionality to do Event Studies}
-%\VignetteDepends{}
-%\VignetteKeywords{event studies}
-%\VignettePackage{eventstudies}
-
-\maketitle
-\newpage
-\SweaveOpts{engine=R,pdf=TRUE}
-\section{Introduction}
-This is an introduction to eventstudies, a package in R which has functionality to convert a given dataset into 
-an event-time frame and to undertake further parametric/non-parametric analysis using various inference procedures.
-
-This paper describes how this package is used and provides several examples illustrating the use of 
-the functionality within this package.
-
-\section{phys2eventtime}
-phys2eventtime is a function which takes a zoo object containing input data, a data frame containing 
-the date of occurance of the events and creates a data frame which is indexed according to the event
-time. 
-
-The following illustrates the use of phys2eventtime.
-<<>>=
-options(useFancyQuotes=FALSE)
-library(eventstudies)
-input.zoo.object <- structure(c(33.16, 34.0967, 35.3683, 34.46, 34.17, 35.89, 36.19,
-                 37.1317, 36.7033, 37.7933, 37.8533, 285.325, 292.6,
-                 290.025, 286.2, 290.075, 295.05, 289.325, 285.625,
-                 293.7, 298.5, 289.05, 704.5438, 708.35, 735.8375,
-                 710.625, 711.65, 731.0125, 727.575, 715.0187, 724.2,
-                 713.1875, 695.1812), .Dim = c(11L, 3L), .Dimnames =
-                 list( NULL, c("ITC", "Reliance", "Infosys")), index =
-                 structure(c(12418, 12419, 12422, 12423, 12424, 12425,
-                 12426, 12429, 12430, 12431, 12432), class = "Date"),
-                 class = "zoo")
-input.zoo.object
-eventslist <- data.frame(unit=c("ITC","Reliance","Infosys",
-                           "ITC","Reliance","Junk"),
-                            when=as.Date(c(
-                           "2004-01-02", "2004-01-08", "2004-01-14",
-                           "2005-01-15", "2004-01-01", "2005-01-01")))
-
-eventslist$unit <- as.character(eventslist$unit)
-eventslist
-@
-In this example we note the following about input.zoo.object and the data frame eventslist:-
-\begin{enumerate}
-\item Prior to event date(in eventslist\$when) there is only 1 reading in the corresponding unit in input.zoo.object.
-\item The event date is within the range of available dates for the corresponding unit(this is the ideal case).
-\item After the event date there's only 1 reading.
-\item The date is not within the range.
-\item There is no data prior to this date.
-\item Unit does not exist in input.zoo.object.
-\end{enumerate}
-
-This is exactly what the second component of phys2eventtime namely outcomes,reports. The first component of the result of phys2eventtime
-is a zoo object which is the event time data frame.
-<<>>==
-a <- phys2eventtime(input.zoo.object, eventslist,width=0)
-str(a)
-a$z.e
-a$outcomes
-
-@
-phys2eventtime has a third parameter namely width which allows for checking that no more than 4 consecutive missing observations
-are there within the given width from the event time.
-
-What we expect if we don't use width handling:-
-<<>>==
-rawres <- structure(list(z.e = structure(c(NA, NA, NA, NA, NA, NA,
-  NA, NA, 33.16, 34.0967, 35.3683, 34.46, 34.17, 35.89, 36.19,
-  37.1317, 36.7033, 37.7933, 37.8533, NA, NA, NA, NA, 285.325, 292.6,
-  290.025, 286.2, 290.075, 295.05, 289.325, 285.625, 293.7, 298.5,
-  289.05, NA, NA, NA, NA, 704.5438, 708.35, 735.8375, 710.625, 711.65,
-  731.0125, 727.575, 715.0187, 724.2, 713.1875, 695.1812, NA, NA, NA,
-  NA, NA, NA, NA, NA), .Dim = c(19L, 3L), .Dimnames = list( NULL,
-  c("1", "2", "3")), index = -9:9, class = "zoo"), outcomes =
-  structure(c(1L, 1L, 1L, 3L, 3L, 2L), .Label = c("success",
-  "unitmissing", "wrongspan" ), class = "factor")), .Names = c("z.e",
-  "outcomes"))
-rawres
-@
-Check without the width handling --
-<<>>==
-a <- phys2eventtime(input.zoo.object, eventslist,width=0)
-a
-all.equal(a, rawres)
-@
-Check with width of 1 --
-<<>>==
-a <- phys2eventtime(input.zoo.object, eventslist,width=1)
-a
-all.equal(a, rawres)
-@
-But when we go to width=2, column 1 and 3 drop off because they have
-only 1 obs before and after the event date respectively.
-
-<<>>==
-a <- phys2eventtime(input.zoo.object, eventslist,width=2)
-a
-all.equal(a, structure(list(z.e = structure(c(NA, NA, NA, NA, 285.325,
-                              292.6, 290.025, 286.2, 290.075, 295.05,
-                              289.325, 285.625, 293.7, 298.5, 289.05,
-                              NA, NA, NA, NA), index = -9:9, class =
-                              "zoo"), outcomes = structure(c(3L, 1L,
-                              3L, 4L, 4L, 2L), .Label = c("success",
-                              "unitmissing", "wdatamissing",
-                              "wrongspan"), class = "factor")), .Names
-                              = c("z.e", "outcomes" )))
-@
-\section{inference.Ecar}
-Once we have an event time frame returned by phys2eventtime we may use inference.Ecar to do 
-bootstrap inference for the main graph of the event study. This is illustrated in the following example.
-<<>>==
-library(xts)
-load(paste(system.file(package="eventstudies"),"data","inr.rda",sep="/"))
-inr.returns<-diff(log(inr))[-1]
-eventslist<-data.frame(unit=rep("inr",10),
-                       when=as.Date(c(
-                         "2010-04-20","2010-07-02","2010-07-27",
-                         "2010-09-16","2010-11-02","2011-01-25",
-                         "2011-03-17","2011-05-03","2011-06-16",
-                         "2011-07-26")))
-event.time.data<-phys2eventtime(inr.returns,eventslist,width=10)
-w<-window(event.time.data$z.e,start=-10,end=10)
-inference.Ecar(w)
-@
-
-\section{identifyextremeevents}
-% Conceptual framework
-This package does eventstudy analysis but if the eventstudy analysis
-is done on extreme events then it is very essential to understand the
-basic pattern and distribution of the extreme events. Here, we define
-extreme events as the upper or lower tail values which are estimated
-with certain probability value. 
-
-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, un-clustered and mixed clusters. For simplicity, we
-remove all the mixed clusters and deal with the rest. Un-clustered 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. 
-
-This function gives following output:
-\begin{itemize}
-\item Summary statistics for complete data-set
-\item Extreme event analysis for lower and upper tail i.e. bad-days
-  and good-days
-  \begin{itemize}
-  \item Dataset: Extreme events
-    \begin{itemize}
-    \item All extreme events
-    \item Clustered extreme events
-    \item Un-clustered extreme events
-    \end{itemize}
-  \item Distribution of clustered and un-clustered data: This measures
-    the number of cluster and un-cluster extreme events in the
-    data-set. Here, cluster which are not used are mixed clusters.
-  \item Run-length distribution of clusters: If there is a cluster
-    then run-length measures the length of consecutive extreme events
-    in a cluster.
-  \item Quantile values of extreme events: 
-  \item Yearly distribution of extreme events: Here we have year-wise
-    distribution of extreme events and their median values.
-  \end{itemize}
-\end{itemize}
-
-% Example for understanding
-<<>>==
-library(xts)
-data(input.data)
-input <- diff(log(input.data[,"sp500"]))
-output <- identifyextremeevents(input, prob.value=5)
-output
-@
-
-\end{document}

Copied: pkg/vignettes/eventstudies.Rnw (from rev 36, pkg/inst/doc/eventstudies.Rnw)
===================================================================
--- pkg/vignettes/eventstudies.Rnw	                        (rev 0)
+++ pkg/vignettes/eventstudies.Rnw	2013-02-11 17:15:41 UTC (rev 39)
@@ -0,0 +1,198 @@
+\documentclass[a4paper,11pt]{article}
+\usepackage{graphicx}
+\usepackage{a4wide}
+\usepackage[colorlinks,linkcolor=blue,citecolor=red]{hyperref}
+\usepackage{natbib}
+\usepackage{float}
+\title{Introduction to the \textbf{eventstudies} package in R}
+\author{}
+\begin{document}
+%\VignetteIndexEntry{eventstudies: A package with functionality to do Event Studies}
+%\VignetteDepends{}
+%\VignetteKeywords{event studies}
+%\VignettePackage{eventstudies}
+
+\maketitle
+\newpage
+\SweaveOpts{engine=R,pdf=TRUE}
+\section{Introduction}
+This is an introduction to eventstudies, a package in R which has functionality to convert a given dataset into 
+an event-time frame and to undertake further parametric/non-parametric analysis using various inference procedures.
+
+This paper describes how this package is used and provides several examples illustrating the use of 
+the functionality within this package.
+
+\section{phys2eventtime}
+phys2eventtime is a function which takes a zoo object containing input data, a data frame containing 
+the date of occurance of the events and creates a data frame which is indexed according to the event
+time. 
+
+The following illustrates the use of phys2eventtime.
+<<>>=
+options(useFancyQuotes=FALSE)
+library(eventstudies)
+input.zoo.object <- structure(c(33.16, 34.0967, 35.3683, 34.46, 34.17, 35.89, 36.19,
+                 37.1317, 36.7033, 37.7933, 37.8533, 285.325, 292.6,
+                 290.025, 286.2, 290.075, 295.05, 289.325, 285.625,
+                 293.7, 298.5, 289.05, 704.5438, 708.35, 735.8375,
+                 710.625, 711.65, 731.0125, 727.575, 715.0187, 724.2,
+                 713.1875, 695.1812), .Dim = c(11L, 3L), .Dimnames =
+                 list( NULL, c("ITC", "Reliance", "Infosys")), index =
+                 structure(c(12418, 12419, 12422, 12423, 12424, 12425,
+                 12426, 12429, 12430, 12431, 12432), class = "Date"),
+                 class = "zoo")
+input.zoo.object
+eventslist <- data.frame(unit=c("ITC","Reliance","Infosys",
+                           "ITC","Reliance","Junk"),
+                            when=as.Date(c(
+                           "2004-01-02", "2004-01-08", "2004-01-14",
+                           "2005-01-15", "2004-01-01", "2005-01-01")))
+
+eventslist$unit <- as.character(eventslist$unit)
+eventslist
+@
+In this example we note the following about input.zoo.object and the data frame eventslist:-
+\begin{enumerate}
+\item Prior to event date(in eventslist\$when) there is only 1 reading in the corresponding unit in input.zoo.object.
+\item The event date is within the range of available dates for the corresponding unit(this is the ideal case).
+\item After the event date there's only 1 reading.
+\item The date is not within the range.
+\item There is no data prior to this date.
+\item Unit does not exist in input.zoo.object.
+\end{enumerate}
+
+This is exactly what the second component of phys2eventtime namely outcomes,reports. The first component of the result of phys2eventtime
+is a zoo object which is the event time data frame.
+<<>>==
+a <- phys2eventtime(input.zoo.object, eventslist,width=0)
+str(a)
+a$z.e
+a$outcomes
+
+@
+phys2eventtime has a third parameter namely width which allows for checking that no more than 4 consecutive missing observations
+are there within the given width from the event time.
+
+What we expect if we don't use width handling:-
+<<>>==
+rawres <- structure(list(z.e = structure(c(NA, NA, NA, NA, NA, NA,
+  NA, NA, 33.16, 34.0967, 35.3683, 34.46, 34.17, 35.89, 36.19,
+  37.1317, 36.7033, 37.7933, 37.8533, NA, NA, NA, NA, 285.325, 292.6,
+  290.025, 286.2, 290.075, 295.05, 289.325, 285.625, 293.7, 298.5,
+  289.05, NA, NA, NA, NA, 704.5438, 708.35, 735.8375, 710.625, 711.65,
+  731.0125, 727.575, 715.0187, 724.2, 713.1875, 695.1812, NA, NA, NA,
+  NA, NA, NA, NA, NA), .Dim = c(19L, 3L), .Dimnames = list( NULL,
+  c("1", "2", "3")), index = -9:9, class = "zoo"), outcomes =
+  structure(c(1L, 1L, 1L, 3L, 3L, 2L), .Label = c("success",
+  "unitmissing", "wrongspan" ), class = "factor")), .Names = c("z.e",
+  "outcomes"))
+rawres
+@
+Check without the width handling --
+<<>>==
+a <- phys2eventtime(input.zoo.object, eventslist,width=0)
+a
+all.equal(a, rawres)
+@
+Check with width of 1 --
+<<>>==
+a <- phys2eventtime(input.zoo.object, eventslist,width=1)
+a
+all.equal(a, rawres)
+@
+But when we go to width=2, column 1 and 3 drop off because they have
+only 1 obs before and after the event date respectively.
+
+<<>>==
+a <- phys2eventtime(input.zoo.object, eventslist,width=2)
+a
+all.equal(a, structure(list(z.e = structure(c(NA, NA, NA, NA, 285.325,
+                              292.6, 290.025, 286.2, 290.075, 295.05,
+                              289.325, 285.625, 293.7, 298.5, 289.05,
+                              NA, NA, NA, NA), index = -9:9, class =
+                              "zoo"), outcomes = structure(c(3L, 1L,
+                              3L, 4L, 4L, 2L), .Label = c("success",
+                              "unitmissing", "wdatamissing",
+                              "wrongspan"), class = "factor")), .Names
+                              = c("z.e", "outcomes" )))
+@
+\section{inference.Ecar}
+Once we have an event time frame returned by phys2eventtime we may use inference.Ecar to do 
+bootstrap inference for the main graph of the event study. This is illustrated in the following example.
+<<>>==
+library(xts)
+load(paste(system.file(package="eventstudies"),"data","inr.rda",sep="/"))
+inr.returns<-diff(log(inr))[-1]
+eventslist<-data.frame(unit=rep("inr",10),
+                       when=as.Date(c(
+                         "2010-04-20","2010-07-02","2010-07-27",
+                         "2010-09-16","2010-11-02","2011-01-25",
+                         "2011-03-17","2011-05-03","2011-06-16",
+                         "2011-07-26")))
+event.time.data<-phys2eventtime(inr.returns,eventslist,width=10)
+w<-window(event.time.data$z.e,start=-10,end=10)
+inference.Ecar(w)
+@
+
+\section{identifyextremeevents}
+% Conceptual framework
+This package does eventstudy analysis but if the eventstudy analysis
+is done on extreme events then it is very essential to understand the
+basic pattern and distribution of the extreme events. Here, we define
+extreme events as the upper or lower tail values which are estimated
+with certain probability value. 
+
+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, un-clustered and mixed clusters. For simplicity, we
+remove all the mixed clusters and deal with the rest. Un-clustered 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. 
+
+This function gives following output:
+\begin{itemize}
+\item Summary statistics for complete data-set
+\item Extreme event analysis for lower and upper tail i.e. bad-days
+  and good-days
+  \begin{itemize}
+  \item Dataset: Extreme events
+    \begin{itemize}
+    \item All extreme events
+    \item Clustered extreme events
+    \item Un-clustered extreme events
+    \end{itemize}
+  \item Distribution of clustered and un-clustered data: This measures
+    the number of cluster and un-cluster extreme events in the
+    data-set. Here, cluster which are not used are mixed clusters.
+  \item Run-length distribution of clusters: If there is a cluster
+    then run-length measures the length of consecutive extreme events
+    in a cluster.
+  \item Quantile values of extreme events: 
+  \item Yearly distribution of extreme events: Here we have year-wise
+    distribution of extreme events and their median values.
+  \end{itemize}
+\end{itemize}
+
+% Example for understanding
+<<>>==
+library(xts)
+data(input.data)
+input <- diff(log(input.data[,"sp500"]))
+output <- identifyextremeevents(input, prob.value=5)
+output
+@
+
+\end{document}



More information about the Eventstudies-commits mailing list