[Eventstudies-commits] r401 - pkg/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sat Dec 6 08:43:23 CET 2014
Author: chiraganand
Date: 2014-12-06 08:43:22 +0100 (Sat, 06 Dec 2014)
New Revision: 401
Modified:
pkg/R/eventstudy.R
Log:
Fixed the lmAMM residuals class, added residuals for excessReturn type.
Modified: pkg/R/eventstudy.R
===================================================================
--- pkg/R/eventstudy.R 2014-12-02 21:00:05 UTC (rev 400)
+++ pkg/R/eventstudy.R 2014-12-06 07:43:22 UTC (rev 401)
@@ -117,6 +117,8 @@
outputModel <- NULL
} else {
outputResiduals <- lapply(outputModel, function(x) attributes(x)[["residuals"]])
+ outputResiduals <- lapply(outputResiduals, function(x)
+ zoo(as.numeric(x), order.by = as.integer(names(x))))
outputModel <- do.call(merge.zoo, outputModel)
}
}
@@ -203,10 +205,11 @@
return(NULL)
}
estimation.period <- attributes(firm)[["estimation.period"]]
- model <- excessReturn(na.locf(firm$z.e[event.period, "firm.returns"]), #XXX: remove na.locf
- na.locf(firm$z.e[event.period, "market.returns"])) #XXX: remove na.locf
+ model <- excessReturn(na.locf(firm$z.e[c(estimation.period, event.period), "firm.returns"]), #XXX: remove na.locf
+ na.locf(firm$z.e[c(estimation.period, event.period), "market.returns"])) #XXX: remove na.locf
- abnormal.returns <- model
+ abnormal.returns <- model[event.period, ]
+ attr(abnormal.returns, "residuals") <- model[estimation.period, ]
return(abnormal.returns)
})
@@ -220,6 +223,7 @@
warning("excessReturn() returned NULL\n")
outputModel <- NULL
} else {
+ outputResiduals <- lapply(outputModel, function(x) attributes(x)[["residuals"]])
outputModel <- do.call(merge.zoo, outputModel[!sapply(outputModel, is.null)])
}
}
More information about the Eventstudies-commits
mailing list