[Returnanalytics-commits] r4022 - in pkg/FactorAnalytics: . R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed May 11 02:46:53 CEST 2016


Author: pragnya
Date: 2016-05-11 02:46:52 +0200 (Wed, 11 May 2016)
New Revision: 4022

Modified:
   pkg/FactorAnalytics/DESCRIPTION
   pkg/FactorAnalytics/R/predict.ffm.R
   pkg/FactorAnalytics/R/predict.tsfm.r
Log:
Fixed bug in predict methods

Modified: pkg/FactorAnalytics/DESCRIPTION
===================================================================
--- pkg/FactorAnalytics/DESCRIPTION	2016-05-09 12:31:39 UTC (rev 4021)
+++ pkg/FactorAnalytics/DESCRIPTION	2016-05-11 00:46:52 UTC (rev 4022)
@@ -1,8 +1,8 @@
 Package: factorAnalytics
 Type: Package
 Title: Factor Analytics
-Version: 2.0.31
-Date: 2016-05-09
+Version: 2.0.32
+Date: 2016-05-10
 Author: Eric Zivot, Sangeetha Srinivasan and Yi-An Chen
 Maintainer: Sangeetha Srinivasan <sangee at uw.edu>
 Description: Linear factor model fitting for asset returns (three major types-

Modified: pkg/FactorAnalytics/R/predict.ffm.R
===================================================================
--- pkg/FactorAnalytics/R/predict.ffm.R	2016-05-09 12:31:39 UTC (rev 4021)
+++ pkg/FactorAnalytics/R/predict.ffm.R	2016-05-11 00:46:52 UTC (rev 4022)
@@ -55,13 +55,14 @@
          of the dates used in the fit")
   }
   
-  if (!is.null(newdata)) {
+  if (is.null(newdata)) {
+    sapply(object$factor.fit, predict, ...)
+  } else {
     newdata <- checkData(newdata, method="data.frame")
+    if (is.null(pred.date)) {
+      sapply(object$factor.fit, predict, newdata, ...)
+    } else {
+      as.matrix(predict(object$factor.fit[[pred.date]], newdata, ...))
+    }
   }
-  
-  if (!is.null(pred.date)) {
-    as.matrix(predict(object$factor.fit[[pred.date]], newdata, ...))
-  } else {
-    sapply(object$factor.fit, predict, newdata, ...)
-  }
 }

Modified: pkg/FactorAnalytics/R/predict.tsfm.r
===================================================================
--- pkg/FactorAnalytics/R/predict.tsfm.r	2016-05-09 12:31:39 UTC (rev 4021)
+++ pkg/FactorAnalytics/R/predict.tsfm.r	2016-05-11 00:46:52 UTC (rev 4022)
@@ -38,8 +38,10 @@
 
 predict.tsfm <- function(object, newdata=NULL, ...){
   
-  if (missing(newdata) || is.null(newdata)) {
+  if (is.null(newdata)) {
+    sapply(object$asset.fit, predict, ...)
+  } else {
     newdata <- checkData(newdata, method="data.frame")
+    sapply(object$asset.fit, predict, newdata, ...)
   }
-  sapply(object$asset.fit, predict, newdata, ...)
 }



More information about the Returnanalytics-commits mailing list