[Eventstudies-commits] r127 - in pkg: R vignettes

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Aug 12 13:44:36 CEST 2013


Author: vikram
Date: 2013-08-12 13:44:36 +0200 (Mon, 12 Aug 2013)
New Revision: 127

Modified:
   pkg/R/AMM.R
   pkg/vignettes/eventstudies.Rnw
Log:
Corrected the excess return, AMM output; modified AMM function to change dates from POSIXct to Date format

Modified: pkg/R/AMM.R
===================================================================
--- pkg/R/AMM.R	2013-08-12 09:45:00 UTC (rev 126)
+++ pkg/R/AMM.R	2013-08-12 11:44:36 UTC (rev 127)
@@ -87,13 +87,15 @@
     
     X <- makeX(market.returns, others, switch.to.innov,
                market.returns.purge, nlags, dates, verbose)
-    result <- xts()
-    for(i in 1:NCOL(firm.returns)){
+    tmp.result <- onefirmAMM(firm.returns[,1], X, nlags, verbose, dates)
+    result <- tmp.result$residuals
+    for(i in 2:NCOL(firm.returns)){
       tmp <- onefirmAMM(firm.returns[,i], X, nlags, verbose, dates)
       result <- merge(result,tmp$residuals)
     }
     colnames(result) <- colnames(firm.returns)
     }
+    index(result) <- as.Date(index(result))
   }
 
   ##----

Modified: pkg/vignettes/eventstudies.Rnw
===================================================================
--- pkg/vignettes/eventstudies.Rnw	2013-08-12 09:45:00 UTC (rev 126)
+++ pkg/vignettes/eventstudies.Rnw	2013-08-12 11:44:36 UTC (rev 127)
@@ -184,8 +184,8 @@
 data(StockPriceReturns)
 data(nifty.index)
 str(StockPriceReturns)
-head(StockPriceReturns)
-head(nifty.index)
+#head(StockPriceReturns)
+#head(nifty.index)
 @ 
 
 \subsection{Calculating returns}
@@ -199,6 +199,7 @@
 # Excess return
 er.result <- excessReturn(firm.returns = StockPriceReturns,
                           market.returns = nifty.index)
+er.result <- er.result[rowSums(is.na(er.result))!=NCOL(er.result),]
 head(er.result[,1:3])
 
 @ 
@@ -206,6 +207,7 @@
 # Extracting market residual
 mm.result <- marketResidual(firm.returns = StockPriceReturns, 
                             market.returns = nifty.index)
+mm.result <- mm.result[rowSums(is.na(mm.result))!=NCOL(mm.result),]
 head(mm.result[,1:3])
 
 @ 
@@ -236,13 +238,13 @@
 ## AMM output
 ## For Full period: dates=NULL
 amm.residual <- AMM(amm.type="residual",firm.returns=StockPriceReturns[,1:3],
-                    verbose=TRUE,
+                    verbose=FALSE,
                     dates= NULL,
                     market.returns=nifty.index, others=inrusd,
-                    switch.to.innov=TRUE, market.returns.purge=TRUE, nlags=1)
+                    switch.to.innov=TRUE, market.returns.purge=TRUE, nlags=0)
 
 amm.output <- AMM(amm.type="all",firm.returns=StockPriceReturns[,1:3],
-                  verbose=TRUE,
+                  verbose=FALSE,
                   dates= NULL,
                   market.returns=nifty.index, others=inrusd,
                   switch.to.innov=TRUE, market.returns.purge=TRUE, nlags=1)
@@ -393,7 +395,7 @@
                      type = "AMM",
                      market.returns=nifty.index,
                      others=inrusd,
-                     verbose=TRUE,
+                     verbose=FALSE,
                      dates= NULL,
                      switch.to.innov=TRUE, market.returns.purge=TRUE, nlags=1)
 



More information about the Eventstudies-commits mailing list