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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Sep 6 16:51:42 CEST 2013


Author: rossbennett34
Date: 2013-09-06 16:51:41 +0200 (Fri, 06 Sep 2013)
New Revision: 3012

Modified:
   pkg/PortfolioAnalytics/R/constrained_objective.R
Log:
Adding weight concentration penalty to constrained_objective

Modified: pkg/PortfolioAnalytics/R/constrained_objective.R
===================================================================
--- pkg/PortfolioAnalytics/R/constrained_objective.R	2013-09-06 10:43:48 UTC (rev 3011)
+++ pkg/PortfolioAnalytics/R/constrained_objective.R	2013-09-06 14:51:41 UTC (rev 3012)
@@ -680,6 +680,22 @@
           }
         } # end handling of risk_budget objective
         
+        if(inherits(objective, "weight_concentration_objective")){
+          # If the user does not pass in conc_groups, the output of HHI will be a scalar
+          if((length(objective$conc_aversion) == 1) & is.null(objective$conc_groups)){
+            # treat conc_aversion as a multiplier
+            out <- out + penalty * objective$conc_aversion * tmp_measure
+          }
+          # If the user passes in conc_groups, the output of HHI will be a list
+          # The second element of the list will be the group HHI
+          if(length(objective$conc_aversion > 1) & !is.null(objective$conc_groups)){
+            if(length(objective$conc_aversion) == length(tmp_measure[[2]])){
+              # treat the conc_aversion vector as a multiplier per group hhi
+              out <- out + penalty * sum(objective$conc_aversion * tmp_measure[[2]])
+            }
+          }
+        } # weight concentration objective
+        
       } # end enabled check
     } # end loop over objectives
   } # end objectives processing



More information about the Returnanalytics-commits mailing list