[Eventstudies-commits] r294 - in pkg: R man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Apr 30 04:13:21 CEST 2014
Author: chiraganand
Date: 2014-04-30 04:13:21 +0200 (Wed, 30 Apr 2014)
New Revision: 294
Modified:
pkg/R/eventstudy.R
pkg/R/lmAMM.R
pkg/man/lmAMM.Rd
Log:
Add axis labels if not provided, fixed AMM variable name in the example.
Modified: pkg/R/eventstudy.R
===================================================================
--- pkg/R/eventstudy.R 2014-04-28 11:28:35 UTC (rev 293)
+++ pkg/R/eventstudy.R 2014-04-30 02:13:21 UTC (rev 294)
@@ -147,11 +147,32 @@
object$outcomes
}
-plot.es <- function(x, ...){
+plot.es <- function(x, xlab = NULL, ylab = NULL, ...){
big <- max(abs(x$eventstudy.output))
hilo <- c(-big,big)
width <- (nrow(x$eventstudy.output)-1)/2
- plot(-width:width, x$eventstudy.output[,2], type="l", lwd=2, ylim=hilo, ...)
+
+ ## assign own labels if they're missing
+ if (is.null(ylab)) {
+ if (x$remap == "cumsum") {
+ remapLabel <- "Cum."
+ } else if (x$remap == "cumprod") {
+ remapLabel <- "Cum. product"
+ } else if (x$remap == "reindex") {
+ remapLabel <- "Re-index"
+ } else {
+ remapLabel <- ""
+ }
+ ylab <- paste0("(", remapLabel, ")", " change in response series (%)")
+ }
+
+ if (is.null(xlab)) {
+ xlab <- "Event time"
+ }
+
+ plot(-width:width, x$eventstudy.output[,2], type="l", lwd=2, ylim=hilo,
+ xlab = xlab, ylab = ylab, ...)
+
points(-width:width, x$eventstudy.output[,2])
lines(-width:width, x$eventstudy.output[,"2.5%"],
lwd=1, lty=2, ...)
Modified: pkg/R/lmAMM.R
===================================================================
--- pkg/R/lmAMM.R 2014-04-28 11:28:35 UTC (rev 293)
+++ pkg/R/lmAMM.R 2014-04-30 02:13:21 UTC (rev 294)
@@ -337,13 +337,24 @@
print.default(x$exposures)
}
-plot.amm <- function(x, ...){
+plot.amm <- function(x, xlab = NULL, ylab = NULL, ...){
tmp.x <- zoo(as.numeric(resid(x)), as.Date(names(resid(x))))
tmp.f <- zoo(x$model$firm.returns, index(tmp.x))
tmp <- merge(tmp.x,tmp.f)
colnames(tmp) <- c("amm.residuals","firm.returns")
- plot(tmp, screen=1, lty=1:2, lwd=2, col=c("indian red", "navy blue"),ylab="",
- xlab="")
- legend("topleft",legend=c("AMM residual","Firm returns"),lty=1:2, lwd=2,
+
+ ## assign own labels if they're missing
+ if (is.null(ylab)) {
+ ylab <- paste0("AMM residuals")
+ }
+
+ if (is.null(xlab)) {
+ xlab <- ""
+ }
+
+ plot(tmp, screen=1, lty=1:2, lwd=2, col=c("indian red", "navy blue"),
+ ylab = ylab, xlab = xlab, ...)
+
+ legend("topleft",legend=c("AMM residual","Firm returns"), lty=1:2, lwd=2,
col=c("indian red", "navy blue"), bty='n')
}
Modified: pkg/man/lmAMM.Rd
===================================================================
--- pkg/man/lmAMM.Rd 2014-04-28 11:28:35 UTC (rev 293)
+++ pkg/man/lmAMM.Rd 2014-04-30 02:13:21 UTC (rev 294)
@@ -96,10 +96,10 @@
amm.result <- lmAMM(firm.returns, X, nlags = 0, verbose = FALSE)
names(amm.result)
amm.residual <- residuals(amm.result)
-amm.result <- zoo(amm.residual,as.Date(names(amm.residual)))
+amm.residual <- zoo(amm.residual,as.Date(names(amm.residual)))
## Checking output: Comparing augmented market model residual, raw returns, nifty returns
-output <- merge(amm.result, StockPriceReturns$Infosys, NiftyIndex,
+output <- merge(amm.residual, StockPriceReturns$Infosys, NiftyIndex,
all=FALSE)
colnames(output) <- c("amm.residual", "raw.returns", "nifty.returns")
tail(output)
More information about the Eventstudies-commits
mailing list