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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Dec 16 00:05:34 CET 2013


Author: rossbennett34
Date: 2013-12-16 00:05:33 +0100 (Mon, 16 Dec 2013)
New Revision: 3280

Modified:
   pkg/PortfolioAnalytics/R/moment.functions.R
   pkg/PortfolioAnalytics/R/optFUN.R
Log:
Modifying bounds for etl_opt and adding mean as an objective name to set.portfolio.moments

Modified: pkg/PortfolioAnalytics/R/moment.functions.R
===================================================================
--- pkg/PortfolioAnalytics/R/moment.functions.R	2013-12-15 23:03:28 UTC (rev 3279)
+++ pkg/PortfolioAnalytics/R/moment.functions.R	2013-12-15 23:05:33 UTC (rev 3280)
@@ -197,6 +197,9 @@
     }
     for (objective in portfolio$objectives){
       switch(objective$name,
+             mean = {
+               if(is.null(momentargs$mu)) momentargs$mu = matrix( as.vector(apply(R,2,'mean', na.rm=TRUE)),ncol=1)
+               },
              sd =,
              StdDev = { 
                if(is.null(momentargs$mu)) momentargs$mu = matrix( as.vector(apply(R,2,'mean', na.rm=TRUE)),ncol=1);

Modified: pkg/PortfolioAnalytics/R/optFUN.R
===================================================================
--- pkg/PortfolioAnalytics/R/optFUN.R	2013-12-15 23:03:28 UTC (rev 3279)
+++ pkg/PortfolioAnalytics/R/optFUN.R	2013-12-15 23:05:33 UTC (rev 3280)
@@ -396,8 +396,10 @@
   N <- ncol(R)
   T <- nrow(R)
   # Applying box constraints
-  bnds <- list(lower=list(ind=seq.int(1L, N), val=as.numeric(constraints$min)),
-               upper=list(ind=seq.int(1L, N), val=as.numeric(constraints$max)))
+  LB <- c(as.numeric(constraints$min), rep(0, T), -1)
+  UB <- c(as.numeric(constraints$max), rep(Inf, T), 1)
+  bnds <- V_bound(li=seq.int(1L, N+T+1), lb=LB,
+                  ui=seq.int(1L, N+T+1), ub=UB)
   
   # Add this check if mean is not an objective and return is a constraints
   if(!is.na(target)){



More information about the Returnanalytics-commits mailing list