[Eventstudies-commits] r285 - in pkg: . R man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Apr 3 19:06:22 CEST 2014


Author: chiraganand
Date: 2014-04-03 19:06:22 +0200 (Thu, 03 Apr 2014)
New Revision: 285

Modified:
   pkg/DESCRIPTION
   pkg/NAMESPACE
   pkg/R/eventstudy.R
   pkg/R/inference.bootstrap.R
   pkg/R/marketResidual.R
   pkg/man/inference.bootstrap.Rd
   pkg/man/inference.wilcox.Rd
   pkg/man/manyfirmssubperiod.lmAMM.Rd
   pkg/man/remap.cumprod.Rd
   pkg/man/remap.event.reindex.Rd
Log:
Rd files updated and some syntax changes also complete. NAMESPACE updated to import various libraries and DESCRIPTION date upated.

Modified: pkg/DESCRIPTION
===================================================================
--- pkg/DESCRIPTION	2014-04-03 15:20:27 UTC (rev 284)
+++ pkg/DESCRIPTION	2014-04-03 17:06:22 UTC (rev 285)
@@ -2,7 +2,7 @@
 Type: Package
 Title: Event study analysis
 Version: 1.2
-Date: 2014-03-28
+Date: 2014-04-03
 Author: Chirag Anand, Vikram Bahure, Vimal Balasubramaniam, Ajay Shah
 Maintainer: Vikram Bahure <economics.vikram at gmail.com>
 Depends: R (>= 2.12.0), zoo, xts, boot, testthat, sandwich

Modified: pkg/NAMESPACE
===================================================================
--- pkg/NAMESPACE	2014-04-03 15:20:27 UTC (rev 284)
+++ pkg/NAMESPACE	2014-04-03 17:06:22 UTC (rev 285)
@@ -1,7 +1,9 @@
 export(eventstudy, inference.bootstrap, inference.wilcox, phys2eventtime,
        remap.cumsum, remap.cumprod, remap.event.reindex, ees, eesPlot)
+
 export(marketResidual,
        excessReturn)
+
 export(subperiod.lmAMM, manyfirmssubperiod.lmAMM, lmAMM, makeX)
 
 
@@ -13,3 +15,5 @@
 
 S3method(plot, amm)
 S3method(plot, es)
+
+import(boot,sandwich,testthat,xts,zoo)

Modified: pkg/R/eventstudy.R
===================================================================
--- pkg/R/eventstudy.R	2014-04-03 15:20:27 UTC (rev 284)
+++ pkg/R/eventstudy.R	2014-04-03 17:06:22 UTC (rev 285)
@@ -2,7 +2,7 @@
                        eventList,
                        width = 10,
                        is.levels =  FALSE,
-                       type = "None",
+                       type = "marketResidual",
                        to.remap = TRUE,
                        remap = "cumsum",
                        inference = TRUE,

Modified: pkg/R/inference.bootstrap.R
===================================================================
--- pkg/R/inference.bootstrap.R	2014-04-03 15:20:27 UTC (rev 284)
+++ pkg/R/inference.bootstrap.R	2014-04-03 17:06:22 UTC (rev 285)
@@ -48,6 +48,7 @@
 # This function does bootstrap inference for the entire
 # Ecar, i.e. main graph of the event study.
 inference.bootstrap <- function(es.w, to.plot=TRUE,
+                                boot.run=1000,
                                 xlab = "Event time",
                                 ylab = "Cumulative returns of response series",
                                 main = "Event study plot") {
@@ -55,7 +56,8 @@
     colMeans(transposed[d,], na.rm=TRUE)
   }
   tmp <- t(as.matrix(es.w))
-  b <- boot(tmp, Ecar, R=1000)
+  b <- boot(tmp, Ecar, R=boot.run)
+  
 
   results <- NULL
   for (i in 1:ncol(b$t)) {

Modified: pkg/R/marketResidual.R
===================================================================
--- pkg/R/marketResidual.R	2014-04-03 15:20:27 UTC (rev 284)
+++ pkg/R/marketResidual.R	2014-04-03 17:06:22 UTC (rev 285)
@@ -15,7 +15,10 @@
     
     fulldata <- merge(x,y,all=TRUE)
     fulldata <- window(fulldata,start=startdate,end=enddate)
-    
+    if (length(fulldata) == 0) {
+      warning("no common window found");
+      return(NULL)
+    }
     ## Storing NA observations
     non.na.loc <- complete.cases(fulldata)
     fulldata <- fulldata[complete.cases(fulldata),]
@@ -30,12 +33,16 @@
   
   ## Checking
   if(NCOL(firm.returns)>1){
-    result <- NULL
-    for(i in 1:NCOL(firm.returns)){
-      res <- mm.residual(y=firm.returns[,i],x=market.returns)
-      result <- merge(result,res,all=TRUE)
+    result <- lapply(firm.returns, function(i)
+           {
+             mm.residual(y=i,x=market.returns)
+           })
+    names(result) <- colnames(firm.returns)
+    chk <- which(do.call("c",lapply(result,is.null))==TRUE)
+    if(length(chk)!=0){
+      result <- result[-chk]
     }
-    colnames(result) <- colnames(firm.returns)
+    result <- do.call("merge.zoo", result)
   } else {
     result <- mm.residual(y=firm.returns,x=market.returns)
   }

Modified: pkg/man/inference.bootstrap.Rd
===================================================================
--- pkg/man/inference.bootstrap.Rd	2014-04-03 15:20:27 UTC (rev 284)
+++ pkg/man/inference.bootstrap.Rd	2014-04-03 17:06:22 UTC (rev 285)
@@ -1,16 +1,17 @@
 \name{inference.bootstrap}
 \alias{inference.bootstrap}
 
-\title{Do bootstrap inference for event study analysis}
+\title{Bootstrap inference for event study estimator}
 
 \description{
-  This function does bootstrap inference to generate distribution of
-  average of all the cumulative returns time-series.
+  This function obtains a boostrapped confidence interval for estimates
+  of magnitude over the event horizon. 
 }
 
 \usage{
 inference.bootstrap(es.w,
                    to.plot = TRUE,
+                   boot.run = 1000,
                    xlab = "Event time", 
 		   ylab = "Cumulative returns of response series", 
 		   main = "Event study plot")
@@ -18,11 +19,16 @@
 
 \arguments{
   \item{es.w}{
-    a \pkg{zoo} series indexed by event time: the \dQuote{z.e}
+    a \pkg{zoo} object indexed by event time: the \dQuote{z.e}
     component of the list returned by the \code{\link{phys2eventtime}}
     function.
   }
 
+  \item{boot.run}{
+    A \sQuote{numeric}, controlling the number of simulations required
+    for the bootstrap.
+  }
+
   \item{to.plot}{a \sQuote{logical} indicating whether to generate an
     eventstudy plot of the inference estimated. Defaults to
     \sQuote{TRUE}.
@@ -38,12 +44,6 @@
     \sQuote{TRUE}.}
 }
 
-%% FIXME: more details
-\details{
-  Function \sQuote{boot} from package \pkg{boot} is used for
-  bootstrapping with \emph{replicates} of 1000.
-}
-
 \value{
   A \sQuote{matrix} with 3 columns, the lower confidence interval
   (CI), the mean, and the upper CI which are the result of bootstrap

Modified: pkg/man/inference.wilcox.Rd
===================================================================
--- pkg/man/inference.wilcox.Rd	2014-04-03 15:20:27 UTC (rev 284)
+++ pkg/man/inference.wilcox.Rd	2014-04-03 17:06:22 UTC (rev 285)
@@ -20,15 +20,17 @@
 
 \arguments{
  
-  \item{es.w}{a \pkg{zoo} series indexed by event time. It is the
-    \dQuote{z.e} component of the list returned by function
-    \dQuote{phys2eventtime}.}
+  \item{es.w}{
+    a \pkg{zoo} object indexed by event time: the \dQuote{z.e}
+    component of the list returned by the \code{\link{phys2eventtime}}
+    function.
+  }
 
-  \item{to.plot}{a \sQuote{logical}. indicating whether to  generate an
+  \item{to.plot}{a \sQuote{logical} indicating whether to generate an
     eventstudy plot of the inference estimated. Defaults to
     \sQuote{TRUE}.
   }
-
+  
   \item{xlab}{the x-axis label of the generated plot. Used if
     \dQuote{to.plot} is \sQuote{TRUE}.}
   
@@ -39,7 +41,6 @@
     \sQuote{TRUE}.}
 }
 
-%% FIXME: add \details section?
 
 \value{A \sQuote{matrix} with 3 columns: the lower confidence interval (CI),
   the mean, and the upper CI which are the result of wilcox inference.}
@@ -59,6 +60,5 @@
                              width = 5)
 es.w <- window(es.results$z.e, start = -5, end = +5)
 eventtime <- remap.cumsum(es.w, is.pc = FALSE, base = 0)
-infr <- inference.wilcox(es.w = eventtime, to.plot = FALSE)
-head(infr)
+inference.wilcox(es.w = eventtime, to.plot = FALSE)
 }

Modified: pkg/man/manyfirmssubperiod.lmAMM.Rd
===================================================================
--- pkg/man/manyfirmssubperiod.lmAMM.Rd	2014-04-03 15:20:27 UTC (rev 284)
+++ pkg/man/manyfirmssubperiod.lmAMM.Rd	2014-04-03 17:06:22 UTC (rev 285)
@@ -1,10 +1,10 @@
 \name{manyfirmssubperiod.lmAMM}
 \alias{manyfirmssubperiod.lmAMM}
 
-\title{Estimate exposure for multiple regressors over multiple periods.}
+\title{Estimate exposure for many regressands over multiple periods.}
 
 \description{\code{\link{manyfirmssubperiod.lmAMM}} estimates exposure
-  for multiple regressands over a set of regressors obtained by using
+  for many regressands over a set of regressors obtained by using
   \sQuote{makeX} over multiple periods.
   }
 

Modified: pkg/man/remap.cumprod.Rd
===================================================================
--- pkg/man/remap.cumprod.Rd	2014-04-03 15:20:27 UTC (rev 284)
+++ pkg/man/remap.cumprod.Rd	2014-04-03 17:06:22 UTC (rev 285)
@@ -42,5 +42,6 @@
                            is.pc = TRUE,
                            is.returns = TRUE,
                            base = 100)
+head(eventtime[,1:5])
 }
-head(eventtime[,1:5])
+

Modified: pkg/man/remap.event.reindex.Rd
===================================================================
--- pkg/man/remap.event.reindex.Rd	2014-04-03 15:20:27 UTC (rev 284)
+++ pkg/man/remap.event.reindex.Rd	2014-04-03 17:06:22 UTC (rev 285)
@@ -11,9 +11,10 @@
 
 \usage{remap.event.reindex(z)}
 
-\arguments{  
+\arguments{
   \item{z}{z is a zoo object obtained from
-  \code{\link{phys2eventtime}}. 
+    \code{\link{phys2eventtime}}. 
+  }
 }
 
 \value{Rescaled returns value}



More information about the Eventstudies-commits mailing list