[Eventstudies-commits] r76 - pkg/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue Jul 16 07:16:51 CEST 2013
Author: chiraganand
Date: 2013-07-16 07:16:50 +0200 (Tue, 16 Jul 2013)
New Revision: 76
Added:
pkg/R/eventstudy.R
Log:
Added main wrapper function for eventstudies.
Added: pkg/R/eventstudy.R
===================================================================
--- pkg/R/eventstudy.R (rev 0)
+++ pkg/R/eventstudy.R 2013-07-16 05:16:50 UTC (rev 76)
@@ -0,0 +1,46 @@
+eventstudy <- function(inputData = NULL,
+ eventList,
+ width = 10,
+ type = "marketResiduals",
+ to.remap = TRUE,
+ remap = "cumsum",
+ to.plot = TRUE,
+ ...) {
+ # type = "marketResiduals", "excessReturn", "AMM", "None"
+ if (type == "None" && !is.null(inputData)) {
+ outputModel <- inputData
+ } else {
+ stop("inputData or \"None\" type missing")
+ }
+
+### Run models
+ ## AMM
+ if (type == "AMM") {
+ outputModel <- AMM(...)
+ }
+
+ ## marketResiduals
+ if (type == "marketResiduals") {
+ outputModel <- marketResiduals(...)
+ }
+
+ ## excessReturn
+ if (type == "excessReturn") {
+ outputModel <- excessReturn(...)
+ }
+
+### Convert to event frame
+ es <- phys2eventtime(z=outputModel, events=eventList, width=width)
+ es.w <- window(es$z.e, start = -width, end = width)
+
+### Remapping event frame
+ if (to.remap == TRUE) {
+ es.w <- switch(remap,
+ cumsum = remap.cumsum(es.w, is.pc = FALSE, base = 0),
+ cumprod = remap.cumprod(es.w, is.pc = TRUE, is.returns = TRUE, base = 100),
+ reindex = remap.event.reindex(es.w)
+ )
+ }
+
+### Bootstrap
+ result <- inference.Ecar(z.e = es.w, to.plot = to.plot)
More information about the Eventstudies-commits
mailing list