[Eventstudies-commits] r185 - pkg/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sat Mar 8 18:47:51 CET 2014


Author: vikram
Date: 2014-03-08 18:47:51 +0100 (Sat, 08 Mar 2014)
New Revision: 185

Modified:
   pkg/R/remap.cumprod.R
   pkg/R/remap.cumsum.R
Log:
Fixed the remap function to have first value as zero and start cumulative abnormal returns from there

Modified: pkg/R/remap.cumprod.R
===================================================================
--- pkg/R/remap.cumprod.R	2014-03-03 09:39:26 UTC (rev 184)
+++ pkg/R/remap.cumprod.R	2014-03-08 17:47:51 UTC (rev 185)
@@ -6,6 +6,7 @@
 # is.returns is false                         in this case is.pc is ignored!
 #    values are like 1.01 for 1%
 remap.cumprod <- function(z, is.pc=TRUE, is.returns=TRUE, base=100) {
+  z <- firstValueZero(z)
   for (i in 1:NCOL(z)) {
     tmp <- z[,i]
     if (is.returns) {
@@ -23,3 +24,12 @@
   }
   z
 }
+
+firstValueZero <- function(x){
+  if(NCOL(x)==1){
+    x[1] <- 0
+  } else {
+    x[1,] <- 0
+  }
+  return(x)
+}

Modified: pkg/R/remap.cumsum.R
===================================================================
--- pkg/R/remap.cumsum.R	2014-03-03 09:39:26 UTC (rev 184)
+++ pkg/R/remap.cumsum.R	2014-03-08 17:47:51 UTC (rev 185)
@@ -1,6 +1,7 @@
 
 # If is.pc then a value like "1" means 0.01
 remap.cumsum <- function(z, is.pc=TRUE, base=0) {
+  z <- firstValueZero(z)
   for (i in 1:NCOL(z)) {
     tmp <- z[,i]
     if (is.pc) {
@@ -14,3 +15,12 @@
   }
   z
 }
+
+firstValueZero <- function(x){
+  if(NCOL(x)==1){
+    x[1] <- 0
+  } else {
+    x[1,] <- 0
+  }
+  return(x)
+}



More information about the Eventstudies-commits mailing list