[Eventstudies-commits] r417 - pkg/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Apr 8 17:23:15 CEST 2015
Author: sargam_jain
Date: 2015-04-08 17:23:14 +0200 (Wed, 08 Apr 2015)
New Revision: 417
Modified:
pkg/R/eventstudy.R
pkg/R/inference.bootstrap.R
pkg/R/remap.cumsum.R
Log:
Changes in the code for univariate series.
Modified: pkg/R/eventstudy.R
===================================================================
--- pkg/R/eventstudy.R 2015-04-08 15:07:37 UTC (rev 416)
+++ pkg/R/eventstudy.R 2015-04-08 15:23:14 UTC (rev 417)
@@ -269,11 +269,15 @@
### Remapping event frame
if (to.remap == TRUE) {
outputModel <- switch(remap,
- cumsum = remap.cumsum(outputModel, is.pc = FALSE, base = 0),
- cumprod = remap.cumprod(outputModel, is.pc = TRUE,
- is.returns = TRUE, base = 100),
- reindex = remap.event.reindex(outputModel)
- )
+ cumsum = remap.cumsum(outputModel, is.pc = FALSE, base = 0),
+ cumprod = remap.cumprod(outputModel, is.pc = TRUE,
+ is.returns = TRUE, base = 100),
+ reindex = remap.event.reindex(outputModel)
+ )
+ car <- outputModel
+ if(inference == FALSE){
+ outputModel <- ifelse(NCOL(outputModel) != 1, rowMeans(outputModel), mean(outputModel))
+ }
remapping <- remap
} else {
remapping <- "none"
@@ -297,6 +301,10 @@
if (exists("outputResiduals")) {
attr(final.result, which = "model.residuals") <- outputResiduals
}
+
+ if (exists("car")) {
+ attr(final.result, which = "CAR") <- car
+ }
attr(final.result, which = "event.window") <- event.window
attr(final.result, which = "inference") <- inference
if (inference == TRUE) {
Modified: pkg/R/inference.bootstrap.R
===================================================================
--- pkg/R/inference.bootstrap.R 2015-04-08 15:07:37 UTC (rev 416)
+++ pkg/R/inference.bootstrap.R 2015-04-08 15:23:14 UTC (rev 417)
@@ -53,7 +53,7 @@
ylab = "Cumulative returns of response series",
main = "Event study plot") {
Ecar <- function(transposed, d) {
- colMeans(transposed[d,], na.rm=TRUE)
+ colMeans(transposed[d, , drop=FALSE], na.rm=TRUE)
}
tmp <- t(as.matrix(es.w))
b <- boot(tmp, Ecar, R=boot.run)
Modified: pkg/R/remap.cumsum.R
===================================================================
--- pkg/R/remap.cumsum.R 2015-04-08 15:07:37 UTC (rev 416)
+++ pkg/R/remap.cumsum.R 2015-04-08 15:23:14 UTC (rev 417)
@@ -8,7 +8,7 @@
tmp <- tmp/100
}
if(NCOL(z)==1){
- z <- tmp
+ z <- base+cumsum(tmp)
} else {
z[,i] <- base+cumsum(tmp)
}
@@ -18,8 +18,8 @@
firstValueZero <- function(x){
if(NCOL(x)==1){
- x[1] <- 0
- } else {
+ x[1] <- 0
+ } else {
x[1,] <- 0
}
return(x)
More information about the Eventstudies-commits
mailing list