[Eventstudies-commits] r219 - pkg/vignettes

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Mar 25 14:42:41 CET 2014


Author: vikram
Date: 2014-03-25 14:42:41 +0100 (Tue, 25 Mar 2014)
New Revision: 219

Modified:
   pkg/vignettes/eventstudies.Rnw
Log:
Modified vignette code

Modified: pkg/vignettes/eventstudies.Rnw
===================================================================
--- pkg/vignettes/eventstudies.Rnw	2014-03-25 09:15:27 UTC (rev 218)
+++ pkg/vignettes/eventstudies.Rnw	2014-03-25 13:42:41 UTC (rev 219)
@@ -169,6 +169,12 @@
 <<>>= 
 data(SplitDates) 
 head(SplitDates) 
+data(inr) 
+inrusd <- diff(log(inr))*100
+all.data <- merge(StockPriceReturns,nifty.index,inrusd,all=TRUE) 
+StockPriceReturns <- all.data[,-which(colnames(all.data)%in%c("nifty.index", "inr"))] 
+nifty.index <- all.data$nifty.index 
+inrusd <- all.data$inr
 @
 
 \subsection{Calculating idiosyncratic returns}
@@ -213,13 +219,6 @@
 
 % AMM model
 <<>>= # Create RHS before running lmAMM() 
-data(inr) 
-inrusd <- diff(log(inr))*100
-all.data <- merge(StockPriceReturns,nifty.index,inrusd,all=TRUE) 
-StockPriceReturns <- all.data[,-which(colnames(all.data)%in%c("nifty.index", "inr"))] 
-nifty.index <- all.data$nifty.index 
-inrusd <- all.data$inr
-
 ###################
 ## AMM residuals ##
 ###################
@@ -238,7 +237,7 @@
 ## More than one firm
                                         # Extracting and merging
 tmp.resid <- sapply(colnames(StockPriceReturns)[1:3],function(y)
-                    timeseriesAMM(firm.returns=StockPriceReturns[,y],
+                    timeseries.lmAMM(firm.returns=StockPriceReturns[,y],
                                   X=regressors,
                                   verbose=FALSE,
                                   nlags=1))
@@ -280,7 +279,7 @@
 \textit{inference.bootstrap} performs the bootstrap to generate distribution of $\overline{CR}$. The bootstrap generates confidence interval at 2.5 percent and 97.5 percent for the estimate.
 
 <<>>= 
-result <- inference.bootstrap(es.w=es.cs, to.plot=TRUE) 
+result <- inference.bootstrap(es.w=es.cs, to.plot=FALSE) 
 print(result)
 @
 
@@ -291,7 +290,11 @@
     \setkeys{Gin}{width=0.8\linewidth}
     \setkeys{Gin}{height=0.8\linewidth} 
 <<fig=TRUE,echo=FALSE>>=
-result <- inference.bootstrap(es.w=es.cs, to.plot=TRUE) 
+es.na.btsp <- eventstudy(firm.returns = StockPriceReturns, 
+                    eventList = SplitDates, width = 10, to.remap = TRUE,
+                    remap = "cumsum", inference = TRUE, 
+                    inference.strategy = "bootstrap", type = "None")       
+plot.es(es.na.btsp)
 @
   \end{center}
   \label{fig:one}
@@ -301,8 +304,8 @@
 Another non-parametric inference available and is used widely with event study analysis is the Wilcoxon signed rank test. This package provides a wrapper that uses the function \texttt{wilcox.test} in \texttt{stats}. 
 
 <<>>= 
-result <- inference.wilcox(es.w=es.cs, to.plot=TRUE) 
-result
+result <- inference.wilcox(es.w=es.cs, to.plot=FALSE) 
+print(result)
 @
 
 \begin{figure}[t]
@@ -312,7 +315,11 @@
     \setkeys{Gin}{width=0.8\linewidth}
     \setkeys{Gin}{height=0.8\linewidth} 
 <<fig=TRUE,echo=FALSE>>=
-result <- inference.wilcox(es.w=es.cs, to.plot=TRUE) 
+es.na.wcx <- eventstudy(firm.returns = StockPriceReturns, 
+                    eventList = SplitDates, width = 10, to.remap = TRUE,
+                    remap = "cumsum", inference = TRUE, 
+                    inference.strategy = "wilcox", type = "None")
+plot(es.na.wcx)
 @
   \end{center}
   \label{fig:two}



More information about the Eventstudies-commits mailing list