[Eventstudies-commits] r217 - pkg/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Mon Mar 24 22:47:13 CET 2014
Author: chiraganand
Date: 2014-03-24 22:47:13 +0100 (Mon, 24 Mar 2014)
New Revision: 217
Modified:
pkg/R/eventstudy.R
pkg/R/lmAmm.R
Log:
Fixed S3 generic function consistency.
Modified: pkg/R/eventstudy.R
===================================================================
--- pkg/R/eventstudy.R 2014-03-24 20:29:47 UTC (rev 216)
+++ pkg/R/eventstudy.R 2014-03-24 21:47:13 UTC (rev 217)
@@ -105,33 +105,33 @@
#########################
## Functions for class es
#########################
-print.es <- function(es.object){
- cat("The", es.object$inference, "inference output for CI and",
- colnames(es.object$eventstudy.output)[2], "response:", "\n")
- return(es.object$eventstudy.output)
+print.es <- function(x, ...){
+ cat("The", x$inference, "inference output for CI and",
+ colnames(x$eventstudy.output)[2], "response:", "\n")
+ return(x$eventstudy.output)
}
-summary.es <- function(es.object){
- cat("Event study", colnames(es.object$eventstudy.output)[2], "response with",
- es.object$inference, "inference for CI:\n")
- print(es.object$eventstudy.output)
- cat("\n","Event outcome has",length(which(es.object$outcomes=="success")),
- "successful outcomes out of", length(es.object$outcomes),"events:","\n")
- es.object$outcomes
+summary.es <- function(object, ...){
+ cat("Event study", colnames(object$eventstudy.output)[2], "response with",
+ object$inference, "inference for CI:\n")
+ print(object$eventstudy.output)
+ cat("\n","Event outcome has",length(which(object$outcomes=="success")),
+ "successful outcomes out of", length(object$outcomes),"events:","\n")
+ object$outcomes
}
-plot.es <- function(es.object, xlab="Event time",
+plot.es <- function(x, xlab="Event time",
ylab="", main="", col.es="dark slate blue"){
- big <- max(abs(es.object$eventstudy.output))
+ big <- max(abs(x$eventstudy.output))
hilo <- c(-big,big)
- width <- (nrow(es.object$eventstudy.output)-1)/2
- plot(-width:width, es.object$eventstudy.output[,2], type="l", lwd=2, ylim=hilo,
+ width <- (nrow(x$eventstudy.output)-1)/2
+ plot(-width:width, x$eventstudy.output[,2], type="l", lwd=2, ylim=hilo,
col=col.es,xlab= xlab, ylab = ylab,
main=paste(main))
- points(-width:width, es.object$eventstudy.output[,2])
- lines(-width:width, es.object$eventstudy.output[,"2.5%"],
+ points(-width:width, x$eventstudy.output[,2])
+ lines(-width:width, x$eventstudy.output[,"2.5%"],
lwd=1, lty=2, col=col.es)
- lines(-width:width, es.object$eventstudy.output[,"97.5%"],
+ lines(-width:width, x$eventstudy.output[,"97.5%"],
lwd=1, lty=2, col=col.es)
abline(h=0,v=0)
}
Modified: pkg/R/lmAmm.R
===================================================================
--- pkg/R/lmAmm.R 2014-03-24 20:29:47 UTC (rev 216)
+++ pkg/R/lmAmm.R 2014-03-24 21:47:13 UTC (rev 217)
@@ -331,28 +331,30 @@
############################################
## Summary, print and plot functions for AMM
############################################
-summary.amm <- function(amm) {
+summary.amm <- function(object, ...) {
cat("\n", "Summary statistics of exposure: \n")
- sstats <- cbind(amm$exposure, amm$s.exposure,
- amm$exposure/amm$s.exposure)
+ sstats <- cbind(object$exposure, object$s.exposure,
+ object$exposure/object$s.exposure)
colnames(sstats) <- c("Exposure", "Std.Err", "t statistic")
- rownames(sstats) <- names(amm$exposures)
+ rownames(sstats) <- names(object$exposures)
print(sstats)
- cat("\n","Linear model AMM results: ","\n"); class(amm) <- "lm"; print(summary(amm))
+ cat("\n","Linear model AMM results: ","\n");
+ class(object) <- "lm";
+ print.default(summary.default(object))
}
-print.amm <- function(amm){
+print.amm <- function(x, ...){
cat("\n")
- print(amm$call)
+ print(x$call)
cat("\n","Coefficients:","\n")
- print(amm$coef)
+ print(x$coef)
cat("\n","Exposures:","\n")
- print(amm$exposures)
+ print.default(x$exposures)
}
-plot.amm <- function(amm){
- tmp.x <- zoo(as.numeric(resid(amm)), as.Date(names(resid(amm))))
- tmp.f <- zoo(amm$model$firm.returns, index(tmp.x))
+plot.amm <- function(x, ...){
+ 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="",
More information about the Eventstudies-commits
mailing list