[Returnanalytics-commits] r2816 - in pkg/PortfolioAnalytics: . R man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Aug 18 14:19:32 CEST 2013


Author: braverock
Date: 2013-08-18 14:19:32 +0200 (Sun, 18 Aug 2013)
New Revision: 2816

Added:
   pkg/PortfolioAnalytics/man/extractObjectiveMeasures.Rd
Removed:
   pkg/PortfolioAnalytics/man/add.objective_v1.Rd
   pkg/PortfolioAnalytics/man/add.objective_v2.Rd
   pkg/PortfolioAnalytics/man/constrained_objective_v1.Rd
   pkg/PortfolioAnalytics/man/constrained_objective_v2.Rd
   pkg/PortfolioAnalytics/man/constraint_fnMap.Rd
   pkg/PortfolioAnalytics/man/constraint_fn_map.Rd
   pkg/PortfolioAnalytics/man/constraint_v1.Rd
   pkg/PortfolioAnalytics/man/constraint_v2.Rd
   pkg/PortfolioAnalytics/man/extractWeights.rebal.Rd
   pkg/PortfolioAnalytics/man/get.constraints.Rd
   pkg/PortfolioAnalytics/man/optimize.portfolio.rebalancing_v1.Rd
   pkg/PortfolioAnalytics/man/optimize.portfolio_v1.Rd
   pkg/PortfolioAnalytics/man/optimize.portfolio_v2.Rd
   pkg/PortfolioAnalytics/man/random_portfolios_v2.Rd
   pkg/PortfolioAnalytics/man/randomize_portfolio_v2.Rd
   pkg/PortfolioAnalytics/man/set.portfolio.moments_v2.Rd
   pkg/PortfolioAnalytics/man/volatility_constraint.Rd
Modified:
   pkg/PortfolioAnalytics/DESCRIPTION
   pkg/PortfolioAnalytics/R/constrained_objective.R
   pkg/PortfolioAnalytics/R/constraints.R
   pkg/PortfolioAnalytics/R/objective.R
   pkg/PortfolioAnalytics/R/objectiveFUN.R
   pkg/PortfolioAnalytics/R/optimize.portfolio.R
   pkg/PortfolioAnalytics/R/portfolio.R
   pkg/PortfolioAnalytics/man/add.constraint.Rd
   pkg/PortfolioAnalytics/man/add.objective.Rd
   pkg/PortfolioAnalytics/man/constrained_objective.Rd
   pkg/PortfolioAnalytics/man/constraint.Rd
   pkg/PortfolioAnalytics/man/is.objective.Rd
   pkg/PortfolioAnalytics/man/minmax_objective.Rd
   pkg/PortfolioAnalytics/man/objective.Rd
   pkg/PortfolioAnalytics/man/optimize.portfolio.Rd
   pkg/PortfolioAnalytics/man/optimize.portfolio.rebalancing.Rd
   pkg/PortfolioAnalytics/man/portfolio.spec.Rd
Log:
- update roxygen comments to remove a lot of duplication in the docs
- add cross-references
- standardize on non-versioned function names


Modified: pkg/PortfolioAnalytics/DESCRIPTION
===================================================================
--- pkg/PortfolioAnalytics/DESCRIPTION	2013-08-18 09:14:30 UTC (rev 2815)
+++ pkg/PortfolioAnalytics/DESCRIPTION	2013-08-18 12:19:32 UTC (rev 2816)
@@ -2,7 +2,7 @@
 Type: Package
 Title: Portfolio Analysis, including Numeric Methods for Optimization
     of Portfolios
-Version: 0.8.2
+Version: 0.8.3
 Date: $Date$
 Author: Kris Boudt, Peter Carl, Brian G. Peterson
 Contributors: Hezky Varon, Guy Yollin

Modified: pkg/PortfolioAnalytics/R/constrained_objective.R
===================================================================
--- pkg/PortfolioAnalytics/R/constrained_objective.R	2013-08-18 09:14:30 UTC (rev 2815)
+++ pkg/PortfolioAnalytics/R/constrained_objective.R	2013-08-18 12:19:32 UTC (rev 2816)
@@ -15,52 +15,8 @@
 # TODO add more details about the nuances of the optimization engines
 
 
-#' function to calculate a numeric return value for a portfolio based on a set of constraints
-#' 
-#' function to calculate a numeric return value for a portfolio based on a set of constraints,
-#' we'll try to make as few assumptions as possible, and only run objectives that are required by the user
-#' 
-#' If the user has passed in either min_sum or max_sum constraints for the portfolio, or both, 
-#' and are using a numerical optimization method like DEoptim, and normalize=TRUE, the default,
-#' we'll normalize the weights passed in to whichever boundary condition has been violated.  
-#' If using random portfolios, all the portfolios generated will meet the constraints by construction.
-#' NOTE: this means that the weights produced by a numeric optimization algorithm like DEoptim
-#' might violate your constraints, so you'd need to renormalize them after optimizing
-#' We apply the same normalization in \code{\link{optimize.portfolio}} so that the weights you see have been 
-#' normalized to min_sum if the generated portfolio is smaller than min_sum or max_sum if the 
-#' generated portfolio is larger than max_sum.  
-#' This normalization increases the speed of optimization and convergence by several orders of magnitude in many cases.
-#' 
-#' You may find that for some portfolios, normalization is not desirable, if the algorithm 
-#' cannot find a direction in which to move to head towards an optimal portfolio.  In these cases, 
-#' it may be best to set normalize=FALSE, and penalize the portfolios if the sum of the weighting 
-#' vector lies outside the min_sum and/or max_sum.
-#' 
-#' Whether or not we normalize the weights using min_sum and max_sum, and are using a numerical optimization 
-#' engine like DEoptim, we will penalize portfolios that violate weight constraints in much the same way
-#' we penalize other constraints.  If a min_sum/max_sum normalization has not occurred, convergence
-#' can take a very long time.  We currently do not allow for a non-normalized full investment constraint.  
-#' Future version of this function could include this additional constraint penalty. 
-#'  
-#' When you are optimizing a return objective, you must specify a negative multiplier 
-#' for the return objective so that the function will maximize return.  If you specify a target return,
-#' any return less than your target will be penalized.  If you do not specify a target return, 
-#' you may need to specify a negative VTR (value to reach) , or the function will not converge.  
-#' Try the maximum expected return times the multiplier (e.g. -1 or -10).  
-#' Adding a return objective defaults the multiplier to -1.
-#' 
-#' Additional parameters for random portfolios or \code{\link[DEoptim]{DEoptim.control}} may be passed in via \dots
-#' 
-#'    
-#' @param R an xts, vector, matrix, data frame, timeSeries or zoo object of asset returns
-#' @param w a vector of weights to test
-#' @param constraints an object of type "constraints" specifying the constraints for the optimization, see \code{\link{constraint}}
-#' @param \dots any other passthru parameters 
-#' @param trace TRUE/FALSE whether to include debugging and additional detail in the output list
-#' @param normalize TRUE/FALSE whether to normalize results to min/max sum (TRUE), or let the optimizer penalize portfolios that do not conform (FALSE)
-#' @param storage TRUE/FALSE default TRUE for DEoptim with trace, otherwise FALSE. not typically user-called
-#' @seealso \code{\link{constraint}}, \code{\link{objective}}, \code{\link[DEoptim]{DEoptim.control}} 
-#' @author Kris Boudt, Peter Carl, Brian G. Peterson
+#' @rdname constrained_objective
+#' @name constrained_objective
 #' @export
 constrained_objective_v1 <- function(w, R, constraints, ..., trace=FALSE, normalize=TRUE, storage=FALSE)
 { 
@@ -336,7 +292,7 @@
     }
 }
 
-#' constrained_objective_v2 function to calculate a numeric return value for a portfolio based on a set of constraints and objectives
+#' calculate a numeric return value for a portfolio based on a set of constraints and objectives
 #' 
 #' function to calculate a numeric return value for a portfolio based on a set of constraints,
 #' we'll try to make as few assumptions as possible, and only run objectives that are required by the user
@@ -370,7 +326,10 @@
 #' Try the maximum expected return times the multiplier (e.g. -1 or -10).  
 #' Adding a return objective defaults the multiplier to -1.
 #' 
-#' Additional parameters for random portfolios or \code{\link[DEoptim]{DEoptim.control}} may be passed in via \dots
+#' Additional parameters for other solvers 
+#' (e.g. random portfolios or 
+#' \code{\link[DEoptim]{DEoptim.control}} or pso or GenSA 
+#' may be passed in via \dots
 #' 
 #'    
 #' @param R an xts, vector, matrix, data frame, timeSeries or zoo object of asset returns
@@ -744,5 +703,7 @@
 }
 
 # Alias constrained_objective_v2 to constrained_objective
+#' @rdname constrained_objective
+#' @name constrained_objective
 #' @export
 constrained_objective <- constrained_objective_v2
\ No newline at end of file

Modified: pkg/PortfolioAnalytics/R/constraints.R
===================================================================
--- pkg/PortfolioAnalytics/R/constraints.R	2013-08-18 09:14:30 UTC (rev 2815)
+++ pkg/PortfolioAnalytics/R/constraints.R	2013-08-18 12:19:32 UTC (rev 2816)
@@ -12,6 +12,11 @@
 
 #' constructor for class constraint
 #' 
+#' This function is the constructior for the constraint object stored in the 
+#' \code{\link{portfolio.spec}} object.
+#' 
+#' See main documentation in \code{\link{add.constraint}}
+#' 
 #' @param assets number of assets, or optionally a named vector of assets specifying seed weights
 #' @param ... any other passthru parameters
 #' @param min numeric or named vector specifying minimum weight box constraints
@@ -21,7 +26,13 @@
 #' @param min_sum minimum sum of all asset weights, default .99
 #' @param max_sum maximum sum of all asset weights, default 1.01
 #' @param weight_seq seed sequence of weights, see \code{\link{generatesequence}}
-#' @author Peter Carl and Brian G. Peterson
+#' @param type character type of the constraint to add or update
+#' @param assets number of assets, or optionally a named vector of assets specifying seed weights
+#' @param ... any other passthru parameters
+#' @param constrclass character to name the constraint class
+#' @author Peter Carl, Brian G. Peterson, Ross Bennett
+#' @aliases contraint_v1, constraint_v2
+#' @seealso \code{\link{add.constraint}}
 #' @examples 
 #' exconstr <- constraint(assets=10, min_sum=1, max_sum=1, min=.01, max=.35, weight_seq=generatesequence())
 #' @export
@@ -152,15 +163,7 @@
 }
 
 
-#' constructor for class v2_constraint
-#' 
-#' This function is called by the constructor for the specific constraint.
-#' 
-#' @param type character type of the constraint to add or update
-#' @param assets number of assets, or optionally a named vector of assets specifying seed weights
-#' @param ... any other passthru parameters
-#' @param constrclass character to name the constraint class
-#' @author Ross Bennett
+#' @rdname constraint 
 #' @export
 constraint_v2 <- function(type, enabled=TRUE, ..., constrclass="v2_constraint"){
   if(!hasArg(type)) stop("you must specify a constraint type")
@@ -181,21 +184,21 @@
 
 #' General interface for adding and/or updating optimization constraints.
 #' 
-#' This is the main function for adding and/or updating constraints to the \code{{portfolio}} object.
+#' This is the main function for adding and/or updating constraints to the \code{\link{portfolio.spec}} object.
 #' 
-#' The following constraint types are supported:
+#' The following constraint types may be specified:
 #' \itemize{
-#' \item{\code{weight_sum}, \code{weight}, \code{leverage}}{ Specify constraint on the sum of the weights, see \code{\link{weight_sum_constraint}}}
-#' \item{\code{full_investment}}{ Special case to set \code{min_sum=1} and \code{max_sum=1} of weight sum constraints}
-#' \item{\code{dollar_neutral}, \code{active}}{ Special case to set \code{min_sum=0} and \code{max_sum=0} of weight sum constraints}
-#' \item{\code{box}}{ Specify constraints for the individual asset weights, see \code{\link{box_constraint}}}
-#' \item{\code{long_only}}{ Special case to set \code{min=0} and \code{max=1} of box constraints}
-#' \item{\code{group}}{ Specify a constraint on the sum of weights within groups and the number of assets with non-zero weights in groups, see \code{\link{group_constraint}}}
-#' \item{\code{turnover}}{ Specify a constraint for target turnover. Turnover is calculated from a set of initial weights, see \code{\link{turnover_constraint}}}
-#' \item{\code{diversification}}{ Specify a constraint for target diversification of a set of weights, see \code{\link{diversification_constraint}}}
-#' \item{\code{position_limit}}{ Specify a constraint on the number of positions (i.e. assets with non-zero weights as well as the number of long and short positions, see \code{\link{position_limit_constraint}}}
-#' \item{\code{return}}{ Specify a constraint for target mean return, see \code{\link{return_constraint}}}
-#' \item{\code{factor_exposure}}{ Specify a constraint for risk factor exposures, see \code{\link{factor_exposure_constraint}}}
+#' \item{\code{weight_sum}, \code{weight}, \code{leverage}}{ Specify constraint on the sum of the weights, see \code{\link{weight_sum_constraint}} }
+#' \item{\code{full_investment}}{ Special case to set \code{min_sum=1} and \code{max_sum=1} of weight sum constraints }
+#' \item{\code{dollar_neutral}, \code{active}}{ Special case to set \code{min_sum=0} and \code{max_sum=0} of weight sum constraints }
+#' \item{\code{box}}{ box constraints for the individual asset weights, see \code{\link{box_constraint}} }
+#' \item{\code{long_only}}{ Special case to set \code{min=0} and \code{max=1} of box constraints }
+#' \item{\code{group}}{ specify the sum of weights within groups and the number of assets with non-zero weights in groups, see \code{\link{group_constraint}} }
+#' \item{\code{turnover}}{ Specify a constraint for target turnover. Turnover is calculated from a set of initial weights, see \code{\link{turnover_constraint}} }
+#' \item{\code{diversification}}{ target diversification of a set of weights, see \code{\link{diversification_constraint}} }
+#' \item{\code{position_limit}}{ Specify the number of non-zero positions, see \code{\link{position_limit_constraint}} }
+#' \item{\code{return}}{ Specify the target mean return, see \code{\link{return_constraint}}}
+#' \item{\code{factor_exposure}}{ Specify risk factor exposures, see \code{\link{factor_exposure_constraint}}}
 #' }
 #' 
 #' @param portfolio an object of class 'portfolio' to add the constraint to, specifying the constraints for the optimization, see \code{\link{portfolio.spec}}
@@ -205,7 +208,16 @@
 #' @param \dots any other passthru parameters to specify constraints
 #' @param indexnum if you are updating a specific constraint, the index number in the $constraints list to update
 #' @author Ross Bennett
-#' @seealso \code{\link{weight_sum_constraint}}, \code{\link{box_constraint}}, \code{\link{group_constraint}}, \code{\link{turnover_constraint}}, \code{\link{diversification_constraint}}, \code{\link{position_limit_constraint}, \code{\link{return_constraint}, \code{\link{factor_exposure_constraint}}
+#' @seealso 
+#' \code{\link{portfolio.spec}}
+#' \code{\link{weight_sum_constraint}}, 
+#' \code{\link{box_constraint}}, 
+#' \code{\link{group_constraint}}, 
+#' \code{\link{turnover_constraint}}, 
+#' \code{\link{diversification_constraint}}, 
+#' \code{\link{position_limit_constraint}}, 
+#' \code{\link{return_constraint}}, 
+#' \code{\link{factor_exposure_constraint}}
 #' @examples
 #' data(edhec)
 #' returns <- edhec[, 1:4]

Modified: pkg/PortfolioAnalytics/R/objective.R
===================================================================
--- pkg/PortfolioAnalytics/R/objective.R	2013-08-18 09:14:30 UTC (rev 2815)
+++ pkg/PortfolioAnalytics/R/objective.R	2013-08-18 12:19:32 UTC (rev 2816)
@@ -12,6 +12,9 @@
 
 #' constructor for class 'objective'
 #' 
+#' Typically called as a sub-function by the user function \code{\link{add.objective}}.
+#' See main documentation there.
+#' 
 #' @param name name of the objective which will be used to call a function, like 'ES', 'VaR', 'mean'
 #' @param target univariate target for the objective, default NULL
 #' @param arguments default arguments to be passed to an objective function when executed
@@ -19,6 +22,8 @@
 #' @param \dots any other passthrough parameters
 #' @param multiplier multiplier to apply to the objective, usually 1 or -1
 #' @param objclass string class to apply, default 'objective'
+#' @param x an object potentially of type 'objective' to test
+#' @seealso \code{\link{add.objective}}, \code{\link{portfolio.spec}}
 #' @author Brian G. Peterson
 #' @export
 objective<-function(name , target=NULL , arguments, enabled=TRUE , ..., multiplier=1, objclass='objective'){
@@ -43,32 +48,14 @@
 
 
 #' check class of an objective object
-#' @param x an object potentially of type 'objective' to test
 #' @author Brian G. Peterson
 #' @export
 is.objective <- function( x ) {
   inherits( x, "objective" )
 }
 
-#' General interface for adding optimization objectives, including risk, return, and risk budget
-#' 
-#' This function is the main function for adding and updating business objectives in an object of type \code{\link{constraint}}.
-#' 
-#' In general, you will define your objective as one of three types: 'return', 'risk', or 'risk_budget'.  
-#' These have special handling and intelligent defaults for dealing with the function most likely to be 
-#' used as objectives, including mean, median, VaR, ES, etc.
-#' 
-#' @param constraints an object of type "constraints" to add the objective to, specifying the constraints for the optimization, see \code{\link{constraint}}
-#' @param type character type of the objective to add or update, currently 'return','risk', or 'risk_budget'
-#' @param name name of the objective, should correspond to a function, though we will try to make allowances
-#' @param arguments default arguments to be passed to an objective function when executed
-#' @param enabled TRUE/FALSE
-#' @param \dots any other passthru parameters 
-#' @param indexnum if you are updating a specific constraint, the index number in the $objectives list to update
-#' @author Brian G. Peterson
-#' 
-#' @seealso \code{\link{constraint}}
-#' 
+#' @rdname add.objective
+#' @name add.objective
 #' @export
 add.objective_v1 <- function(constraints, type, name, arguments=NULL, enabled=TRUE, ..., indexnum=NULL)
 {
@@ -131,26 +118,8 @@
     return(constraints)
 }
 
-#' General interface for adding optimization objectives, including risk, return, and risk budget
-#' 
-#' This function is the main function for adding and updating business objectives in an object of type \code{\link{portfolio}}.
-#' 
-#' In general, you will define your objective as one of three types: 'return', 'risk', or 'risk_budget'.  
-#' These have special handling and intelligent defaults for dealing with the function most likely to be 
-#' used as objectives, including mean, median, VaR, ES, etc.
-#' 
-#' @param portfolio an object of type 'portfolio' to add the objective to, specifying the portfolio for the optimization, see \code{\link{portfolio}}
-#' @param type character type of the objective to add or update, currently 'return','risk', or 'risk_budget'
-#' @param name name of the objective, should correspond to a function, though we will try to make allowances
-#' @param arguments default arguments to be passed to an objective function when executed
-#' @param enabled TRUE/FALSE
-#' @param \dots any other passthru parameters 
-#' @param indexnum if you are updating a specific constraint, the index number in the $objectives list to update
-#' @author Brian G. Peterson and Ross Bennett
-#' @aliases add.objective
 #' @rdname add.objective
-#' @seealso \code{\link{objective}}
-#' 
+#' @name add.objective
 #' @export
 add.objective_v2 <- function(portfolio, type, name, arguments=NULL, enabled=TRUE, ..., indexnum=NULL){
   # This function is based on the original add.objective function, but modified
@@ -216,7 +185,30 @@
   return(portfolio)
 }
 
-# Alias add.objective_v2 to add.objective
+#' General interface for adding optimization objectives, including risk, return, and risk budget
+#' 
+#' This function is the main function for adding and updating business objectives in an object of type \code{\link{portfolio.spec}}.
+#' 
+#' In general, you will define your objective as one of three types: 'return', 'risk', or 'risk_budget'.  
+#' These have special handling and intelligent defaults for dealing with the function most likely to be 
+#' used as objectives, including mean, median, VaR, ES, etc.
+#' 
+#' Objectives of type 'turnove' and 'minmax' are also supported.
+#' 
+#' @param portfolio an object of type 'portfolio' to add the objective to, specifying the portfolio for the optimization, see \code{\link{portfolio}}
+#' @param type character type of the objective to add or update, currently 'return','risk', or 'risk_budget'
+#' @param name name of the objective, should correspond to a function, though we will try to make allowances
+#' @param arguments default arguments to be passed to an objective function when executed
+#' @param enabled TRUE/FALSE
+#' @param \dots any other passthru parameters 
+#' @param indexnum if you are updating a specific constraint, the index number in the $objectives list to update
+#' @param constraints an object of type "constraints" to add the objective to, specifying the constraints for the optimization, see \code{\link{constraint}} (for _v1 objectives only)
+#' @author Brian G. Peterson and Ross Bennett
+#' @aliases 
+#' add.objective_v2, add.objective_v1
+#' @seealso \code{\link{objective}}, \code{\link{portfolio.spec}}
+#' @rdname add.objective
+#' @name add.objective
 #' @export
 add.objective <- add.objective_v2
 
@@ -352,7 +344,7 @@
 
 #' constructor for class tmp_minmax_objective
 #'
-#' I am add this as a temporary objective allowing for a min and max to be specified. Testing
+#' I am adding this as a temporary objective allowing for a min and max to be specified. Testing
 #' to understand how the objective function responds to a range of allowable values. I will
 #' likely add this to the turnover, diversification, and volatility constraints 
 #' allowing the user to specify a range of values.
@@ -409,4 +401,4 @@
   
   portfolio$objectives <- objectives
   return(portfolio)
-}
\ No newline at end of file
+}

Modified: pkg/PortfolioAnalytics/R/objectiveFUN.R
===================================================================
--- pkg/PortfolioAnalytics/R/objectiveFUN.R	2013-08-18 09:14:30 UTC (rev 2815)
+++ pkg/PortfolioAnalytics/R/objectiveFUN.R	2013-08-18 12:19:32 UTC (rev 2816)
@@ -4,6 +4,7 @@
 #' @param weights vector of weights from optimization
 #' @param wts.init vector of initial weights used to calculate turnover from
 #' @author Ross Bennett
+#' @export
 turnover <- function(weights, wts.init=NULL) {
   # turnover function from https://r-forge.r-project.org/scm/viewvc.php/pkg/PortfolioAnalytics/sandbox/script.workshop2012.R?view=markup&root=returnanalytics
   

Modified: pkg/PortfolioAnalytics/R/optimize.portfolio.R
===================================================================
--- pkg/PortfolioAnalytics/R/optimize.portfolio.R	2013-08-18 09:14:30 UTC (rev 2815)
+++ pkg/PortfolioAnalytics/R/optimize.portfolio.R	2013-08-18 12:19:32 UTC (rev 2816)
@@ -10,61 +10,9 @@
 #
 ###############################################################################
 
-#' wrapper for constrained optimization of portfolios
-#' 
-#' This function aims to provide a wrapper for constrained optimization of 
-#' portfolios that allows the user to specify box constraints and business 
-#' objectives.
-#' 
-#' This function currently supports DEoptim and random portfolios as back ends.
-#' Additional back end contributions for Rmetrics, ghyp, etc. would be welcome.
-#'
-#' When using random portfolios, search_size is precisely that, how many 
-#' portfolios to test.  You need to make sure to set your feasible weights 
-#' in generatesequence to make sure you have search_size unique 
-#' portfolios to test, typically by manipulating the 'by' parameter 
-#' to select something smaller than .01 
-#' (I often use .002, as .001 seems like overkill)
-#' 
-#' When using DE, search_size is decomposed into two other parameters 
-#' which it interacts with, NP and itermax.
-#' 
-#' NP, the number of members in each population, is set to cap at 2000 in 
-#' DEoptim, and by default is the number of parameters (assets/weights) *10.
-#' 
-#' itermax, if not passed in dots, defaults to the number of parameters (assets/weights) *50.
-#' 
-#' When using GenSA and want to set \code{verbose=TRUE}, instead use \code{trace}. 
-#' 
-#' The extension to ROI solves a limit type of convex optimization problems:
-#' 1)  Maxmimize portfolio return subject box constraints on weights
-#' 2)  Minimize portfolio variance subject to box constraints (otherwise known as global minimum variance portfolio)
-#' 3)  Minimize portfolio variance subject to box constraints and a desired portfolio return
-#' 4)  Maximize quadratic utility subject to box constraints and risk aversion parameter (this is passed into \code{optimize.portfolio} as as added argument to the \code{constraints} object)
-#' 5)  Mean CVaR optiimization subject to box constraints and target portfolio return
-#' Lastly, because these convex optimization problem are standardized, there is no need for a penalty term. 
-#' Therefore, the \code{multiplier} argument in \code{\link{add.objective}} passed into the complete constraint object are ingnored by the solver. 
-#' ROI also can solve quadratic and linear problems with group constraints by added a \code{groups} argument into the constraints object. 
-#' This argument is a vector with each of its elements the number of assets per group.  
-#' The group constraints, \code{cLO} and \code{cUP}, are also added to the constraints object.
-#' 
-#' For example, if you have 9 assets, and would like to require that the the first 3 assets are in one group, the second 3 are in another, and the third are in another, then you add the grouping by \code{constraints$groups <- c(3,3,3)}.
-#' To apply the constraints that the first group must compose of at least 20% of the weight, the second group 15%, and the third group 10%, and that now signle group should compose of more that 50% of the weight, then you would add the lower group constraint as \code{constraints$cLO <- c(0.20, 0.15, 0.10)} and the upper constraints as \code{constraints$cUP <- rep(0.5,3)}. 
-#' These group constraint can be set for all five optimization problems listed above. 
-#'   
-#' If you would like to interface with \code{optimize.portfolio} using matrix formulations, then use \code{ROI_old}. 
-#'  
-#' @param R an xts, vector, matrix, data frame, timeSeries or zoo object of asset returns
-#' @param constraints an object of type "constraints" specifying the constraints for the optimization, see \code{\link{constraint}}, if using closed for solver, need to pass a \code{\link{constraint_ROI}} object.
-#' @param optimize_method one of "DEoptim", "random", "ROI","ROI_old", "pso", "GenSA".  For using \code{ROI_old}, need to use a constraint_ROI object in constraints. For using \code{ROI}, pass standard \code{constratint} object in \code{constraints} argument.  Presently, ROI has plugins for \code{quadprog} and \code{Rglpk}.
-#' @param search_size integer, how many portfolios to test, default 20,000
-#' @param trace TRUE/FALSE if TRUE will attempt to return additional information on the path or portfolios searched
-#' @param \dots any other passthru parameters
-#' @param rp matrix of random portfolio weights, default NULL, mostly for automated use by rebalancing optimization or repeated tests on same portfolios
-#' @param momentFUN the name of a function to call to set portfolio moments, default \code{\link{set.portfolio.moments}}
-#' 
-#' @return a list containing the optimal weights, some summary statistics, the function call, and optionally trace information 
-#' @author Kris Boudt, Peter Carl, Brian G. Peterson
+
+#' @rdname optimize.portfolio
+#' @name optimize.portfolio
 #' @export
 optimize.portfolio_v1 <- function(
 		R,
@@ -478,68 +426,6 @@
 }
 
 ##### version 2 of optimize.portfolio #####
-#' version 2 wrapper for constrained optimization of portfolios
-#' 
-#' This function aims to provide a wrapper for constrained optimization of 
-#' portfolios that allows the user to specify constraints and business 
-#' objectives.
-#' 
-#' This function currently supports DEoptim, random portfolios, ROI, pso, and GenSA as back ends.
-#' Additional back end contributions for Rmetrics, ghyp, etc. would be welcome.
-#'
-#' When using random portfolios, search_size is precisely that, how many 
-#' portfolios to test.  You need to make sure to set your feasible weights 
-#' in generatesequence to make sure you have search_size unique 
-#' portfolios to test, typically by manipulating the 'by' parameter 
-#' to select something smaller than .01 
-#' (I often use .002, as .001 seems like overkill)
-#' 
-#' When using DE, search_size is decomposed into two other parameters 
-#' which it interacts with, NP and itermax.
-#' 
-#' NP, the number of members in each population, is set to cap at 2000 in 
-#' DEoptim, and by default is the number of parameters (assets/weights) *10.
-#' 
-#' itermax, if not passed in dots, defaults to the number of parameters (assets/weights) *50.
-#' 
-#' When using GenSA and want to set \code{verbose=TRUE}, instead use \code{trace}. 
-#' 
-#' The extension to ROI solves a limited type of convex optimization problems:
-#' \itemize{
-#' \item{Maxmimize portfolio return subject leverage, box, group, position limit, target mean return, and/or factor exposure constraints on weights}
-#' \item{Minimize portfolio variance subject to leverage, box, group, and/or factor exposure constraints (otherwise known as global minimum variance portfolio)}
-#' \item{Minimize portfolio variance subject to leverage, box, group, and/or factor exposure constraints and a desired portfolio return}
-#' \item{Maximize quadratic utility subject to leverage, box, group, target mean return, and/or factor exposure constraints and risk aversion parameter.
-#' (The risk aversion parameter is passed into \code{optimize.portfolio} as an added argument to the \code{portfolio} object)}
-#' \item{Mean CVaR optimization subject to leverage, box, group, position limit, target mean return, and/or factor exposure constraints and target portfolio return}
-#' }
-#' Lastly, because these convex optimization problem are standardized, there is no need for a penalty term. 
-#' Therefore, the \code{multiplier} argument in \code{\link{add.objective}} passed into the complete constraint object are ingnored by the solver.  
-#'   
-#' If you would like to interface with \code{optimize.portfolio} using matrix formulations, then use \code{ROI_old}. 
-#'  
-#' An object of class \code{v1_constraint} can be passed in for the \code{constraints} argument.
-#' The \code{v1_constraint} object was used in the previous 'v1' specification to specify the 
-#' constraints and objectives for the optimization problem, see \code{\link{constraint}}. 
-#' We will attempt to detect if the object passed into the constraints argument 
-#' is a \code{v1_constraint} object and update to the 'v2' specification by adding the 
-#' constraints and objectives to the \code{portfolio} object.
-#'  
-#' @param R an xts, vector, matrix, data frame, timeSeries or zoo object of asset returns
-#' @param portfolio an object of type "portfolio" specifying the constraints and objectives for the optimization
-#' @param constraints default=NULL, a list of constraint objects. An object of class ]v1_constraint' can be passed in here.
-#' @param objectives default=NULL, a list of objective objects
-#' @param optimize_method one of "DEoptim", "random", "ROI","ROI_old", "pso", "GenSA".  For using \code{ROI_old}, need to use a constraint_ROI object in constraints. For using \code{ROI}, pass standard \code{constratint} object in \code{constraints} argument.  Presently, ROI has plugins for \code{quadprog} and \code{Rglpk}.
-#' @param search_size integer, how many portfolios to test, default 20,000
-#' @param trace TRUE/FALSE if TRUE will attempt to return additional information on the path or portfolios searched
-#' @param \dots any other passthru parameters
-#' @param rp matrix of random portfolio weights, default NULL, mostly for automated use by rebalancing optimization or repeated tests on same portfolios
-#' @param momentFUN the name of a function to call to set portfolio moments, default \code{\link{set.portfolio.moments_v2}}
-#' @param message TRUE/FALSE. The default is message=FALSE. Display messages if TRUE.
-#' 
-#' @return a list containing the optimal weights, some summary statistics, the function call, and optionally trace information 
-#' @author Kris Boudt, Peter Carl, Brian G. Peterson
-#' @aliases optimize.portfolio
 #' @rdname optimize.portfolio
 #' @export
 optimize.portfolio_v2 <- function(
@@ -942,31 +828,101 @@
   return(out)
 }
 
-# Alias for optimize.portfolio_
-#' @export
-optimize.portfolio <- optimize.portfolio_v2
-
-#' version 1 portfolio optimization with support for rebalancing or rolling periods
+#' constrained optimization of portfolios
 #' 
-#' This function may eventually be wrapped into optimize.portfolio
+#' This function aims to provide a wrapper for constrained optimization of 
+#' portfolios that allows the user to specify box constraints and business 
+#' objectives.  
+#' It will be the objective function\code{FUN} passed to any supported \R 
+#' optimization solver.
 #' 
-#' For now, we'll set the rebalancing periods here, though I think they should eventually be part of the constraints object
+#' @details
+#' This function currently supports DEoptim and random portfolios as back ends.
+#' Additional back end contributions for Rmetrics, ghyp, etc. would be welcome.
+#'
+#' When using random portfolios, search_size is precisely that, how many 
+#' portfolios to test.  You need to make sure to set your feasible weights 
+#' in generatesequence to make sure you have search_size unique 
+#' portfolios to test, typically by manipulating the 'by' parameter 
+#' to select something smaller than .01 
+#' (I often use .002, as .001 seems like overkill)
 #' 
-#' This function is massively parallel, and will require 'foreach' and we suggest that you register a parallel backend.
+#' When using DE, search_size is decomposed into two other parameters 
+#' which it interacts with, NP and itermax.
 #' 
+#' NP, the number of members in each population, is set to cap at 2000 in 
+#' DEoptim, and by default is the number of parameters (assets/weights) *10.
+#' 
+#' itermax, if not passed in dots, defaults to the number of parameters (assets/weights) *50.
+#' 
+#' When using GenSA and want to set \code{verbose=TRUE}, instead use \code{trace}. 
+#' 
+#' The extension to ROI solves a limited type of convex optimization problems:
+#' \itemize{
+#' \item{Maxmimize portfolio return subject leverage, box, group, position limit, target mean return, and/or factor exposure constraints on weights}
+#' \item{Minimize portfolio variance subject to leverage, box, group, and/or factor exposure constraints (otherwise known as global minimum variance portfolio)}
+#' \item{Minimize portfolio variance subject to leverage, box, group, and/or factor exposure constraints and a desired portfolio return}
+#' \item{Maximize quadratic utility subject to leverage, box, group, target mean return, and/or factor exposure constraints and risk aversion parameter.
+#' (The risk aversion parameter is passed into \code{optimize.portfolio} as an added argument to the \code{portfolio} object)}
+#' \item{Mean CVaR optimization subject to leverage, box, group, position limit, target mean return, and/or factor exposure constraints and target portfolio return}
+#' }
[TRUNCATED]

To get the complete diff run:
    svnlook diff /svnroot/returnanalytics -r 2816


More information about the Returnanalytics-commits mailing list