[Eventstudies-commits] r362 - pkg/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri May 16 22:49:54 CEST 2014


Author: chiraganand
Date: 2014-05-16 22:49:54 +0200 (Fri, 16 May 2014)
New Revision: 362

Modified:
   pkg/R/lmAMM.R
Log:
Continue to next iteration if a NULL is found, don't return NULL. Return NULL only if the best lag could not be found.

Modified: pkg/R/lmAMM.R
===================================================================
--- pkg/R/lmAMM.R	2014-05-16 20:45:56 UTC (rev 361)
+++ pkg/R/lmAMM.R	2014-05-16 20:49:54 UTC (rev 362)
@@ -155,7 +155,7 @@
     bestAIC <- Inf
     for (trylag in 0:min(10,log10(length(firm.returns)))) {
       thism <- do.ols(trylag)
-      if (is.null(m)) {return(NULL)}
+      if (is.null(thism)) {next}
       thisAIC <- AIC(thism, k=log(length(thism$fitted.values)))
       if (verbose) {cat(trylag, " lags, SBC = ", thisAIC, "\n")}
       if (thisAIC < bestAIC) {
@@ -164,6 +164,9 @@
         bestm <- thism
       }
     }
+    if (is.null(bestm)) {
+        return(NULL)
+    }
     nlags <- bestlag
     m <- bestm
   } else {



More information about the Eventstudies-commits mailing list