[Returnanalytics-commits] r2789 - pkg/PortfolioAnalytics/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Aug 15 07:40:53 CEST 2013


Author: rossbennett34
Date: 2013-08-15 07:40:53 +0200 (Thu, 15 Aug 2013)
New Revision: 2789

Modified:
   pkg/PortfolioAnalytics/R/optFUN.R
Log:
calculate the column means of R in gmv_opt for case when var is the only objective specified and moments$mean is not calculated

Modified: pkg/PortfolioAnalytics/R/optFUN.R
===================================================================
--- pkg/PortfolioAnalytics/R/optFUN.R	2013-08-15 00:11:37 UTC (rev 2788)
+++ pkg/PortfolioAnalytics/R/optFUN.R	2013-08-15 05:40:53 UTC (rev 2789)
@@ -14,7 +14,9 @@
   
   # check for a target return
   if(!is.na(target)) {
-    Amat <- rbind(Amat, moments$mean)
+    # If var is the only objective specified, then moments$mean won't be calculated
+    if(all(moments$mean==0)) col_means <- colMeans(R)
+    Amat <- rbind(Amat, col_means)
     dir.vec <- c(dir.vec, "==")
     rhs.vec <- c(rhs.vec, target)
   }



More information about the Returnanalytics-commits mailing list