[Eventstudies-commits] r153 - in pkg: R data inst/tests man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Oct 29 14:34:37 CET 2013


Author: chiraganand
Date: 2013-10-29 14:34:37 +0100 (Tue, 29 Oct 2013)
New Revision: 153

Modified:
   pkg/R/ees.R
   pkg/R/phys2eventtime.R
   pkg/data/SplitDates.rda
   pkg/inst/tests/test_eventstudy.R
   pkg/inst/tests/test_inr_inference.R
   pkg/man/SplitDates.Rd
   pkg/man/eventstudy.Rd
   pkg/man/phys2eventtime.Rd
Log:
Changed phys2eventtime eventslist argument colnames, modified all the related files, tests are passing.

Modified: pkg/R/ees.R
===================================================================
--- pkg/R/ees.R	2013-10-29 10:29:55 UTC (rev 152)
+++ pkg/R/ees.R	2013-10-29 13:34:37 UTC (rev 153)
@@ -3,8 +3,7 @@
 ############################
 # Identifying extreme events
 ############################
-# libraries required
-library(zoo)
+
 #----------------------------------------------------------------
 # INPUT:
 # 'input'     : Data series for which extreme events are 
@@ -811,7 +810,7 @@
 # -using eventstudy package
 #--------------------------
 corecomp <- function(z,dlist,seriesname,width) {
-  events <- data.frame(unit=rep(seriesname, length(dlist)), when=dlist)
+  events <- data.frame(outcome.unit=rep(seriesname, length(dlist)), event.when=dlist)
   es.results <- phys2eventtime(z, events, width=0)
   es.w <- window(es.results$z.e, start=-width, end=+width)
   # Replaing NA's with zeroes

Modified: pkg/R/phys2eventtime.R
===================================================================
--- pkg/R/phys2eventtime.R	2013-10-29 10:29:55 UTC (rev 152)
+++ pkg/R/phys2eventtime.R	2013-10-29 13:34:37 UTC (rev 153)
@@ -1,11 +1,9 @@
-library(zoo)
-
 # Upon input
 #   z is a zoo object containing input data. E.g. this could be all the 
 #     prices of a bunch of stocks. The column name is the unit name.
 #   events is a data.frame containing 2 columns. The first column
-#     ("unit") is the name of the unit. The second column is the date/time
-#     ("when") when the event happened.
+#     ("outcome.unit") is the name of the unit. The second column is the date/time
+#     ("event.when") when the event happened.
 # For each event, the outcome can be:
 #   unitmissing : a unit named in events isn't in z
 #   wrongspan : the event date isn't placed within the span of data for the unit
@@ -13,10 +11,10 @@
 #   success : all is well.
 # A vector of these outcomes is returned.
 phys2eventtime <- function(z, events, width=10) {
-  # Just in case events$unit has been sent in as a factor --
-  events$unit <- as.character(events$unit)
-  if(is.factor(events$when)) stop("Sorry you provided a factor as an index")
-  # Given a zoo time-series z, and an event date "when",
+  # Just in case events$outcome.unit has been sent in as a factor --
+  events$outcome.unit <- as.character(events$outcome.unit)
+  if(is.factor(events$event.when)) stop("Sorry you provided a factor as an index")
+  # Given a zoo time-series z, and an event date "event.when",
   # try to shift this vector into event time, where the event date
   # becomes 0 and all other dates shift correspondingly.
   # If this can't be done, then send back NULL with an error code.

Modified: pkg/data/SplitDates.rda
===================================================================
(Binary files differ)

Modified: pkg/inst/tests/test_eventstudy.R
===================================================================
--- pkg/inst/tests/test_eventstudy.R	2013-10-29 10:29:55 UTC (rev 152)
+++ pkg/inst/tests/test_eventstudy.R	2013-10-29 13:34:37 UTC (rev 153)
@@ -14,12 +14,12 @@
                  12426, 12429, 12430, 12431, 12432), class = "Date"),
                  class = "zoo")
 # An example events list
-eventslist <- data.frame(unit=c("ITC","Reliance","Infosys",
+eventslist <- data.frame(outcome.unit=c("ITC","Reliance","Infosys",
                            "ITC","Reliance","Junk"),
-                         when=as.Date(c(
+                         event.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$outcome.unit <- as.character(eventslist$outcome.unit)
 
 # What we expect if we don't worry about width --
 rawres <- structure(list(z.e = structure(c(NA, NA, NA, NA, NA, NA,

Modified: pkg/inst/tests/test_inr_inference.R
===================================================================
--- pkg/inst/tests/test_inr_inference.R	2013-10-29 10:29:55 UTC (rev 152)
+++ pkg/inst/tests/test_inr_inference.R	2013-10-29 13:34:37 UTC (rev 153)
@@ -7,8 +7,8 @@
 
 inr_returns <- diff(log(inr))[-1]
 
-eventslist <- data.frame(unit=rep("inr",10),
-                         when=as.Date(c(
+eventslist <- data.frame(outcome.unit=rep("inr",10),
+                         event.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",

Modified: pkg/man/SplitDates.Rd
===================================================================
--- pkg/man/SplitDates.Rd	2013-10-29 10:29:55 UTC (rev 152)
+++ pkg/man/SplitDates.Rd	2013-10-29 13:34:37 UTC (rev 153)
@@ -7,7 +7,7 @@
 \title{A set of events to perform eventstudy analysis.}
 
 \description{
-The data contains stock split event dates for the index constituents of the Bombay Stock Exchange index (SENSEX). The data format follows the required format in the function \code{phys2eventtime}, with two columns 'unit' (firm name) and 'when' (stock split date).}
+The data contains stock split event dates for the index constituents of the Bombay Stock Exchange index (SENSEX). The data format follows the required format in the function \code{phys2eventtime}, with two columns 'outcome.unit' (firm name) and 'event.when' (stock split date).}
 
 \usage{data(SplitDates)}
 
@@ -16,4 +16,4 @@
 \examples{
     data(SplitDates)
 }
-\keyword{dataset}
\ No newline at end of file
+\keyword{dataset}

Modified: pkg/man/eventstudy.Rd
===================================================================
--- pkg/man/eventstudy.Rd	2013-10-29 10:29:55 UTC (rev 152)
+++ pkg/man/eventstudy.Rd	2013-10-29 13:34:37 UTC (rev 153)
@@ -23,7 +23,7 @@
 
 \arguments{
   \item{firm.returns}{Data on which event study is to be performed}
-  \item{eventList}{A data frame with event dates. It has two columns 'unit' and 'when'. The first column 'unit' consists of column names of the event stock and 'when' is the respective event date}
+  \item{eventList}{A data frame with event dates. It has two columns 'outcome.unit' and 'event.when'. The first column 'outcome.unit' consists of column names of the event stock and 'event.when' is the respective event date}
   \item{width}{It studies the performance of observations before and after the event}
   \item{type}{This argument gives an option to use different market model adjustment like "marketResidual", "excessReturn", "AMM" and "None"}
   \item{to.remap}{If TRUE then remap the event frame is done}

Modified: pkg/man/phys2eventtime.Rd
===================================================================
--- pkg/man/phys2eventtime.Rd	2013-10-29 10:29:55 UTC (rev 152)
+++ pkg/man/phys2eventtime.Rd	2013-10-29 13:34:37 UTC (rev 153)
@@ -16,9 +16,9 @@
 \arguments{
   \item{z}{Time series data for which event frame is to be generated.}
 
-  \item{events}{It is a data frame with two columns: unit and when. unit
+  \item{events}{It is a data frame with two columns: outcome.unit and event.when. outcome.unit
   has column name of which response is to measured on the event date,
-  while when has the event date. See details.}
+  while event.when has the event date. See details.}
 
   \item{width}{Width corresponds to the number of days on each side of the event date.For a given width, if there is any NA in the event window then the last observation is carried forward.}
 



More information about the Eventstudies-commits mailing list