From noreply at r-forge.r-project.org Sat Nov 9 07:47:01 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 9 Nov 2013 07:47:01 +0100 (CET) Subject: [Eventstudies-commits] r155 - pkg/R Message-ID: <20131109064701.86A18185A4F@r-forge.r-project.org> Author: vikram Date: 2013-11-09 07:47:01 +0100 (Sat, 09 Nov 2013) New Revision: 155 Modified: pkg/R/inference.bootstrap.R Log: Added wilcoxon signed test by replicating the wilcoxon.test code; Coin package is used only for two sample tests but in this we require one sample test Modified: pkg/R/inference.bootstrap.R =================================================================== --- pkg/R/inference.bootstrap.R 2013-10-30 03:22:45 UTC (rev 154) +++ pkg/R/inference.bootstrap.R 2013-11-09 06:47:01 UTC (rev 155) @@ -1,7 +1,6 @@ library(boot) library(zoo) - # This does bootstrap inference for the difference in the # average "car" between t1 and t2 (both in event time). # es.w is a zoo object, where rows are in event time @@ -35,11 +34,11 @@ big <- max(abs(inference)) hilo <- c(-big,big) width <- (nrow(inference)-1)/2 - plot(-width:width, inference[,"Mean"], type="l", lwd=2, ylim=hilo, + plot(-width:width, inference[,2], type="l", lwd=2, ylim=hilo, col="dark slate blue", xlab= xlab, ylab = ylab, main=paste(main)) - points(-width:width, inference[,"Mean"]) + points(-width:width, inference[,2]) lines(-width:width, inference[,"2.5%"], lwd=1, lty=2, col="dark slate blue") lines(-width:width, inference[,"97.5%"], lwd=1, lty=2, col="dark slate blue") abline(h=0,v=0) @@ -79,18 +78,33 @@ ylab = "Cumulative returns of response series", main = "Event study plot" ){ - wx.res <- apply(es.w,1,function(x) - res <- wilcox.exact(x, alternative = "two.sided", - conf.int = TRUE, - conf.level = 0.95)["conf.int"]) - list <- unlist(wx.res, recursive = FALSE) - CI <- do.call(rbind, list) - Mean <- apply(es.w,1,mean,na.rm=TRUE) - result <- cbind(CI[,1], Mean, CI[,2]) - colnames(result) <- c("2.5%","Mean","97.5%") - rownames(result) <- rownames(Mean) + ## Wilcoxon sign test + wilcox.sign.test <- function(x, prob){ + n <- length(x) + m <- n * (n + 1) / 2 + k <- 1:(m / 2) + conf.lev <- 1 - 2 * psignrank(k, n) + no <- round(conf.lev[conf.lev>=prob], 4) + no.f <- length(no) + w <- outer(x, x, "+") / 2 + w <- w[lower.tri(w, diag = TRUE)] + w <- sort(w) + CI <- c(w[no.f + 1], w[m - no.f]) + prob.val <- 1 - 2 * psignrank(no.f, n) + return(CI) + } + ## Extracting confidence interval + CI <- t(apply(es.w,1,function(x) + res <- wilcox.sign.test(x, prob=0.975))) + Median <- apply(es.w,1,median,na.rm=TRUE) + result <- cbind(CI[,1], Median, CI[,2]) + colnames(result) <- c("2.5%","Median","97.5%") + rownames(result) <- rownames(Median) if(to.plot == TRUE){ plotInference(inference = result, xlab, ylab, main) } - return(result) + return(result) } + + + From noreply at r-forge.r-project.org Tue Nov 12 13:04:11 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 12 Nov 2013 13:04:11 +0100 (CET) Subject: [Eventstudies-commits] r156 - in pkg: . vignettes Message-ID: <20131112120411.24B04185A8B@r-forge.r-project.org> Author: vikram Date: 2013-11-12 13:04:10 +0100 (Tue, 12 Nov 2013) New Revision: 156 Modified: pkg/DESCRIPTION pkg/vignettes/eventstudies.Rnw Log: Added AMM vignette to explain Augmented market models and respective code; Modified Description of the package Modified: pkg/DESCRIPTION =================================================================== --- pkg/DESCRIPTION 2013-11-09 06:47:01 UTC (rev 155) +++ pkg/DESCRIPTION 2013-11-12 12:04:10 UTC (rev 156) @@ -1,10 +1,10 @@ Package: eventstudies Type: Package -Title: Event study and extreme event analysis -Version: 1.1 +Title: Event study analysis +Version: 1.2 Author: Ajay Shah, Chirag Anand, Vikram Bahure Maintainer: Vikram Bahure -Depends: R (>= 2.12.0), zoo, xts, boot, testthat, sandwich, exactRankTests, doMC, foreach -Description: Implementation of short and long term event study methodology +Depends: R (>= 2.12.0), zoo, xts, boot, testthat, sandwich, doMC, foreach +Description: Event study methodology in finance and economics; along with augmented market models (AMMs) License: GPL-2 LazyLoad: yes Modified: pkg/vignettes/eventstudies.Rnw =================================================================== --- pkg/vignettes/eventstudies.Rnw 2013-11-09 06:47:01 UTC (rev 155) +++ pkg/vignettes/eventstudies.Rnw 2013-11-12 12:04:10 UTC (rev 156) @@ -181,9 +181,22 @@ @ -To provide flexibility to users, a general multivariate framework to estimate idiosyncratic returns, the augmented market model, is also available. In this case, we would like to purge any currency returns from the outcome return of interest, and the \textit{a-priori} expectation is that the variance of the residual is reduced in this process. In this case, the \texttt{AMM} model requires a time-series of the exchange rate along with firm returns and market returns. This is done by loading the \textit{inr} data, which is the INR-USD exchange rate for the same period. The complete data set consisting of stock returns, market returns, and exchange rate is first created. +To provide flexibility to users, a general multivariate framework to +estimate idiosyncratic returns, the augmented market model, is also +available. In this case, we would like to purge any currency returns +from the outcome return of interest, and the \textit{a-priori} +expectation is that the variance of the residual is reduced in this +process. In this case, the \texttt{AMM} model requires a time-series +of the exchange rate along with firm returns and market returns. This +is done by loading the \textit{inr} data, which is the INR-USD +exchange rate for the same period. The complete data set consisting of +stock returns, market returns, and exchange rate is first created. -Inputs into the \texttt{AMM} model also include \texttt{firm.returns} and \texttt{market.returns}. Currency returns can be specified using \texttt{others}. In a general case, this proves to be a multivariate specification with the flexibility to run auxiliary regressions to specify the regression appropriately. +Inputs into the \texttt{AMM} model also include \texttt{firm.returns} +and \texttt{market.returns}. Currency returns can be specified using +\texttt{others}. In a general case, this proves to be a multivariate +specification with the flexibility to run auxiliary regressions to +specify the regression appropriately. % AMM model <<>>= @@ -338,4 +351,5 @@ % \newpage \bibliographystyle{jss} \bibliography{es} + \end{document} From noreply at r-forge.r-project.org Tue Nov 12 13:30:11 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 12 Nov 2013 13:30:11 +0100 (CET) Subject: [Eventstudies-commits] r157 - pkg Message-ID: <20131112123011.1907218092D@r-forge.r-project.org> Author: chiraganand Date: 2013-11-12 13:30:10 +0100 (Tue, 12 Nov 2013) New Revision: 157 Modified: pkg/DESCRIPTION Log: Decremented the version number again to 1.1 Modified: pkg/DESCRIPTION =================================================================== --- pkg/DESCRIPTION 2013-11-12 12:04:10 UTC (rev 156) +++ pkg/DESCRIPTION 2013-11-12 12:30:10 UTC (rev 157) @@ -1,7 +1,7 @@ Package: eventstudies Type: Package Title: Event study analysis -Version: 1.2 +Version: 1.1 Author: Ajay Shah, Chirag Anand, Vikram Bahure Maintainer: Vikram Bahure Depends: R (>= 2.12.0), zoo, xts, boot, testthat, sandwich, doMC, foreach