[Returnanalytics-commits] r2671 - pkg/FactorAnalytics/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Jul 29 19:53:19 CEST 2013


Author: chenyian
Date: 2013-07-29 19:53:18 +0200 (Mon, 29 Jul 2013)
New Revision: 2671

Modified:
   pkg/FactorAnalytics/R/predict.TimeSeriesFactorModel.r
Log:
add checkData 

Modified: pkg/FactorAnalytics/R/predict.TimeSeriesFactorModel.r
===================================================================
--- pkg/FactorAnalytics/R/predict.TimeSeriesFactorModel.r	2013-07-29 16:57:32 UTC (rev 2670)
+++ pkg/FactorAnalytics/R/predict.TimeSeriesFactorModel.r	2013-07-29 17:53:18 UTC (rev 2671)
@@ -4,6 +4,7 @@
 #' function \code{predict.lm}.
 #' 
 #' @param fit "TimeSeriesFactorModel" object created by fitTimeSeiresFactorModel.
+#' @param newdata a vector, matrix, data.frame, xts, timeSeries or zoo object to be coerced.
 #' @param ... Any other arguments used in \code{predict.lm}. for example newdata and se.fit.
 #' @author Yi-An Chen.
 #' 
@@ -23,11 +24,17 @@
 #' @export
 #' 
 
-predict.TimeSeriesFactorModel <- function(fit.macro,...){
-#   if (missing(newdata) || is.null(newdata)  ) {
+predict.TimeSeriesFactorModel <- function(fit.macro,newdata = NULL,...){
+  require(PerformanceAnalytics)
+ 
+  if (missing(newdata) || is.null(newdata)  ) {
   lapply(fit.macro$asset.fit, predict,...)
-#   } 
-  
+   } else  {
+    newdata <- checkData(newdata,method = "data.frame")
+    lapply(fit.macro$asset.fit, predict ,newdata,... )
+    } 
+
+}
 #   
 #   if (  !(missing(newdata) && !is.null(newdata) )) {
 #    numAssets <- length(names(fit.macro$asset.fit))
@@ -55,4 +62,3 @@
 #   }
   
   
-}
\ No newline at end of file



More information about the Returnanalytics-commits mailing list