[Eventstudies-commits] r330 - pkg/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed May 14 20:56:58 CEST 2014


Author: chiraganand
Date: 2014-05-14 20:56:58 +0200 (Wed, 14 May 2014)
New Revision: 330

Modified:
   pkg/R/eventstudy.R
Log:
Fixed sapply returning a list, fill NAs with 0s after converting to event time.

Modified: pkg/R/eventstudy.R
===================================================================
--- pkg/R/eventstudy.R	2014-05-14 18:19:31 UTC (rev 329)
+++ pkg/R/eventstudy.R	2014-05-14 18:56:58 UTC (rev 330)
@@ -49,15 +49,15 @@
     } else {
       ## More than one firm
                                         # Extracting and merging
-      tmp.resid <- sapply(colnames(firm.returns), function(y)
+      tmp.resid <- lapply(colnames(firm.returns), function(y)
                           {
                             timeseriesAMM(firm.returns = firm.returns[,y],
                                           X = regressors,
                                           verbose = FALSE,
                                           nlags = 1)
                           })
-      outputModel <- zoo(tmp.resid,
-                         order.by = as.Date(rownames(tmp.resid)))
+      names(tmp.resid) <- colnames(firm.returns)
+      outputModel <- do.call(merge.zoo, tmp.resid)
     }
   } ## end AMM
 
@@ -93,6 +93,9 @@
     cn.names <- eventList[which(es$outcomes=="success"),1]
   }
 
+  ## replace NAs with 0 as it's returns now
+  es.w <- na.fill(es.w, 0)
+
   if(length(cn.names)==1){
     cat("Event date exists only for",cn.names,"\n")
     if (inference == TRUE) {



More information about the Eventstudies-commits mailing list