[Eventstudies-commits] r112 - pkg/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue Aug 6 07:32:43 CEST 2013
Author: chiraganand
Date: 2013-08-06 07:32:42 +0200 (Tue, 06 Aug 2013)
New Revision: 112
Modified:
pkg/R/phys2eventtime.R
Log:
Fixed the timeshift function to take the previous date if the exact
event date is not found.
Modified: pkg/R/phys2eventtime.R
===================================================================
--- pkg/R/phys2eventtime.R 2013-08-04 20:02:41 UTC (rev 111)
+++ pkg/R/phys2eventtime.R 2013-08-06 05:32:42 UTC (rev 112)
@@ -27,8 +27,11 @@
if (!firm.present) {
return(list(result=NULL, outcome="unitmissing"))
}
- location <- match(as.Date(x[2]), index(z[,x[1]]), nomatch = -1)
- if (location == -1 | location == 1 | !firm.present) {
+ # take the previous date if
+ # the exact event date is not
+ # found
+ location <- findInterval(as.Date(x[2]), index(z[, x[1]]))
+ if ((location <= 1) | (location >= length(index(z)))) {
return(list(result=NULL, outcome="wrongspan"))
}
remapped <- zoo(as.numeric(z[,x[1]]), order.by=(-location+1):(length(z[,x[1]])-location))
More information about the Eventstudies-commits
mailing list