[Returnanalytics-commits] r2829 - in pkg/PortfolioAnalytics: . R man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Mon Aug 19 21:22:09 CEST 2013
Author: rossbennett34
Date: 2013-08-19 21:22:08 +0200 (Mon, 19 Aug 2013)
New Revision: 2829
Added:
pkg/PortfolioAnalytics/man/var.portfolio.Rd
Modified:
pkg/PortfolioAnalytics/NAMESPACE
pkg/PortfolioAnalytics/R/objective.R
pkg/PortfolioAnalytics/R/optimize.portfolio.R
pkg/PortfolioAnalytics/man/add.objective.Rd
pkg/PortfolioAnalytics/man/optimize.portfolio.Rd
pkg/PortfolioAnalytics/man/optimize.portfolio.rebalancing.Rd
Log:
updating documentation. Primarily adding details of the object returned by optimize.portfolio
Modified: pkg/PortfolioAnalytics/NAMESPACE
===================================================================
--- pkg/PortfolioAnalytics/NAMESPACE 2013-08-19 15:25:13 UTC (rev 2828)
+++ pkg/PortfolioAnalytics/NAMESPACE 2013-08-19 19:22:08 UTC (rev 2829)
@@ -1,6 +1,4 @@
export(add.constraint)
-export(add.objective_v1)
-export(add.objective_v2)
export(add.objective)
export(applyFUN)
export(box_constraint)
@@ -21,7 +19,6 @@
export(charts.ROI)
export(charts.RP)
export(constrained_group_tmp)
-export(constrained_objective_v1)
export(constrained_objective_v2)
export(constrained_objective)
export(constraint_ROI)
@@ -30,6 +27,7 @@
export(diversification_constraint)
export(diversification)
export(extract.efficient.frontier)
+export(extractObjectiveMeasures)
export(extractStats.optimize.portfolio.DEoptim)
export(extractStats.optimize.portfolio.GenSA)
export(extractStats.optimize.portfolio.parallel)
@@ -53,10 +51,8 @@
export(is.portfolio)
export(minmax_objective)
export(objective)
-export(optimize.portfolio_v1)
export(optimize.portfolio_v2)
export(optimize.portfolio.parallel)
-export(optimize.portfolio.rebalancing_v1)
export(optimize.portfolio.rebalancing)
export(optimize.portfolio)
export(plot.optimize.portfolio.DEoptim)
@@ -96,10 +92,12 @@
export(trailingFUN)
export(turnover_constraint)
export(turnover_objective)
+export(turnover)
export(txfrm_box_constraint)
export(txfrm_group_constraint)
export(txfrm_position_limit_constraint)
export(txfrm_weight_sum_constraint)
export(update_constraint_v1tov2)
export(update.constraint)
+export(var.portfolio)
export(weight_sum_constraint)
Modified: pkg/PortfolioAnalytics/R/objective.R
===================================================================
--- pkg/PortfolioAnalytics/R/objective.R 2013-08-19 15:25:13 UTC (rev 2828)
+++ pkg/PortfolioAnalytics/R/objective.R 2013-08-19 19:22:08 UTC (rev 2829)
@@ -200,6 +200,7 @@
#' 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 constraints a 'v1_constraint' object for backwards compatibility, 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
Modified: pkg/PortfolioAnalytics/R/optimize.portfolio.R
===================================================================
--- pkg/PortfolioAnalytics/R/optimize.portfolio.R 2013-08-19 15:25:13 UTC (rev 2828)
+++ pkg/PortfolioAnalytics/R/optimize.portfolio.R 2013-08-19 19:22:08 UTC (rev 2829)
@@ -911,8 +911,8 @@
#'
#' @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 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
@@ -921,10 +921,76 @@
#' @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
+#' @return a list containing the following elements
+#' \itemize{
+#' \item{\code{weights}:}{ The optimal set weights.}
+#' \item{\code{objective_measures}:}{ A list containing the value of each objective corresponding to the optimal weights.}
+#' \item{\code{out}:}{ The output of the solver.}
+#' \item{\code{call}:}{ The function call.}
+#' \item{\code{portfolio}:}{ The portfolio object.}
+#' \item{\code{R}:}{ The asset returns.}
+#' \item{\code{data summary:}}{ The first row and last row of \code{R}.}
+#' \item{\code{elapsed_time:}}{ The amount of time that elapses while the optimization is run.}
+#' \item{\code{end_t:}}{ The date and time the optimization completed.}
+#' }
+#' When Trace=TRUE is specified, the following elements will be returned in
+#' addition to the elements above. The output depends on the optimization
+#' method and is specific to each solver. Refer to the documentation of the
+#' desired solver for more information.
#'
+#' \code{optimize_method="random"}
+#' \itemize{
+#' \item{\code{random_portfolios}:}{ A matrix of the random portfolios.}
+#' \item{\code{random_portfolio_objective_results}:}{ A list of the following elements for each random portfolio.}
+#' \itemize{
+#' \item{\code{out}:}{ The output value of the solver corresponding to the random portfolio weights.}
+#' \item{\code{weights}:}{ The weights of the random portfolio.}
+#' \item{\code{objective_measures}:}{ A list of each objective measure corresponding to the random portfolio weights.}
+#' }
+#' }
+#'
+#' \code{optimize_method="DEoptim"}
+#' \itemize{
+#' \item{\code{DEoutput:}}{ A list (of length 2) containing the following elements, see \code{\link{DEoptim}}.}
+#' \itemize{
+#' \item{\code{optim}}
+#' \item{\code{member}}
+#' }
+#' \item{\code{DEoptim_objective_results}:}{ A list containing the following elements for each intermediate population.}
+#' \itemize{
+#' \item{\code{out}:}{ The output of the solver.}
+#' \item{\code{weights}:}{ Population weights.}
+#' \item{\code{init_weights}:}{ Initial population weights.}
+#' \item{\code{objective_measures}:}{ A list of each objective measure corresponding to the weights}
+#' }
+#' }
+#'
+#' \code{optimize_method="pso"}
+#' \itemize{
+#' \item{\code{PSOoutput}:}{ A list containing the following elements, see \code{\link{psoptim}}:}
+#' \itemize{
+#' \item{par}
+#' \item{value}
+#' \item{counts}
+#' \item{convergence}
+#' \item{message}
+#' \item{stats}
+#' }
+#' }
+#'
+#' \code{optimize_method="GenSA"}
+#' \itemize{
+#' \item{\code{GenSAoutput:}}{ A list containing the following elements, see \code{\link{GenSA}}:}
+#' \itemize{
+#' \item{value}
+#' \item{par}
+#' \item{trace.mat}
+#' \item{counts}
+#' }
+#' }
+#'
#' @author Kris Boudt, Peter Carl, Brian G. Peterson, Ross Bennett
-#' @aliases optimize.portfolio_v2, optimize_portfolio_v1
+#' @aliases optimize.portfolio_v2 optimize_portfolio_v1
#' @seealso \code{\link{portfolio.spec}}
#' @name optimize.portfolio
#' @export
Modified: pkg/PortfolioAnalytics/man/add.objective.Rd
===================================================================
--- pkg/PortfolioAnalytics/man/add.objective.Rd 2013-08-19 15:25:13 UTC (rev 2828)
+++ pkg/PortfolioAnalytics/man/add.objective.Rd 2013-08-19 19:22:08 UTC (rev 2829)
@@ -7,17 +7,21 @@
add.objective_v1(constraints, type, name,
arguments = NULL, enabled = TRUE, ..., indexnum = NULL)
- add.objective_v2(portfolio, type, name, arguments = NULL,
- enabled = TRUE, ..., indexnum = NULL)
+ add.objective_v2(portfolio, constraints = NULL, type,
+ name, arguments = NULL, enabled = TRUE, ...,
+ indexnum = NULL)
- add.objective(portfolio, type, name, arguments = NULL,
- enabled = TRUE, ..., indexnum = NULL)
+ add.objective(portfolio, constraints = NULL, type, name,
+ arguments = NULL, enabled = TRUE, ..., indexnum = NULL)
}
\arguments{
\item{portfolio}{an object of type 'portfolio' to add the
objective to, specifying the portfolio for the
optimization, see \code{\link{portfolio}}}
+ \item{constraints}{a 'v1_constraint' object for backwards
+ compatibility, see \code{\link{constraint}}}
+
\item{type}{character type of the objective to add or
update, currently 'return','risk', or 'risk_budget'}
Modified: pkg/PortfolioAnalytics/man/optimize.portfolio.Rd
===================================================================
--- pkg/PortfolioAnalytics/man/optimize.portfolio.Rd 2013-08-19 15:25:13 UTC (rev 2828)
+++ pkg/PortfolioAnalytics/man/optimize.portfolio.Rd 2013-08-19 19:22:08 UTC (rev 2829)
@@ -1,8 +1,7 @@
\name{optimize.portfolio}
+\alias{optimize_portfolio_v1}
\alias{optimize.portfolio}
-\alias{optimize_portfolio_v1}
\alias{optimize.portfolio_v2}
-\alias{optimize.portfolio_v2,}
\title{constrained optimization of portfolios}
\usage{
optimize.portfolio_v1(R, constraints,
@@ -10,14 +9,14 @@
search_size = 20000, trace = FALSE, ..., rp = NULL,
momentFUN = "set.portfolio.moments_v1")
- optimize.portfolio_v2(R, portfolio, constraints = NULL,
- objectives = NULL,
+ optimize.portfolio_v2(R, portfolio = NULL,
+ constraints = NULL, objectives = NULL,
optimize_method = c("DEoptim", "random", "ROI", "ROI_old", "pso", "GenSA"),
search_size = 20000, trace = FALSE, ..., rp = NULL,
momentFUN = "set.portfolio.moments", message = FALSE)
- optimize.portfolio(R, portfolio, constraints = NULL,
- objectives = NULL,
+ optimize.portfolio(R, portfolio = NULL,
+ constraints = NULL, objectives = NULL,
optimize_method = c("DEoptim", "random", "ROI", "ROI_old", "pso", "GenSA"),
search_size = 20000, trace = FALSE, ..., rp = NULL,
momentFUN = "set.portfolio.moments", message = FALSE)
@@ -30,11 +29,11 @@
the constraints and objectives for the optimization}
\item{constraints}{default=NULL, a list of constraint
- objects. An object of class ]v1_constraint' can be passed
+ objects. An object of class v1_constraint' can be passed
in here.}
\item{objectives}{default=NULL, a list of objective
- objects}
+ objects.}
\item{optimize_method}{one of "DEoptim", "random",
"ROI","ROI_old", "pso", "GenSA". For using
@@ -65,9 +64,59 @@
Display messages if TRUE.}
}
\value{
- a list containing the optimal weights, some summary
- statistics, the function call, and optionally trace
- information
+ a list containing the following elements \itemize{
+ \item{\code{weights}:}{ The optimal set weights.}
+ \item{\code{objective_measures}:}{ A list containing the
+ value of each objective corresponding to the optimal
+ weights.} \item{\code{out}:}{ The output of the solver.}
+ \item{\code{call}:}{ The function call.}
+ \item{\code{portfolio}:}{ The portfolio object.}
+ \item{\code{R}:}{ The asset returns.} \item{\code{data
+ summary:}}{ The first row and last row of \code{R}.}
+ \item{\code{elapsed_time:}}{ The amount of time that
+ elapses while the optimization is run.}
+ \item{\code{end_t:}}{ The date and time the optimization
+ completed.} } When Trace=TRUE is specified, the following
+ elements will be returned in addition to the elements
+ above. The output depends on the optimization method and
+ is specific to each solver. Refer to the documentation of
+ the desired solver for more information.
+
+ \code{optimize_method="random"} \itemize{
+ \item{\code{random_portfolios}:}{ A matrix of the random
+ portfolios.}
+ \item{\code{random_portfolio_objective_results}:}{ A list
+ of the following elements for each random portfolio.}
+ \itemize{ \item{\code{out}:}{ The output value of the
+ solver corresponding to the random portfolio weights.}
+ \item{\code{weights}:}{ The weights of the random
+ portfolio.} \item{\code{objective_measures}:}{ A list of
+ each objective measure corresponding to the random
+ portfolio weights.} } }
+
+ \code{optimize_method="DEoptim"} \itemize{
+ \item{\code{DEoutput:}}{ A list (of length 2) containing
+ the following elements, see \code{\link{DEoptim}}.}
+ \itemize{ \item{\code{optim}} \item{\code{member}} }
+ \item{\code{DEoptim_objective_results}:}{ A list
+ containing the following elements for each intermediate
+ population.} \itemize{ \item{\code{out}:}{ The output of
+ the solver.} \item{\code{weights}:}{ Population weights.}
+ \item{\code{init_weights}:}{ Initial population weights.}
+ \item{\code{objective_measures}:}{ A list of each
+ objective measure corresponding to the weights} } }
+
+ \code{optimize_method="pso"} \itemize{
+ \item{\code{PSOoutput}:}{ A list containing the following
+ elements, see \code{\link{psoptim}}:} \itemize{
+ \item{par} \item{value} \item{counts} \item{convergence}
+ \item{message} \item{stats} } }
+
+ \code{optimize_method="GenSA"} \itemize{
+ \item{\code{GenSAoutput:}}{ A list containing the
+ following elements, see \code{\link{GenSA}}:} \itemize{
+ \item{value} \item{par} \item{trace.mat} \item{counts} }
+ }
}
\description{
This function aims to provide a wrapper for constrained
Modified: pkg/PortfolioAnalytics/man/optimize.portfolio.rebalancing.Rd
===================================================================
--- pkg/PortfolioAnalytics/man/optimize.portfolio.rebalancing.Rd 2013-08-19 15:25:13 UTC (rev 2828)
+++ pkg/PortfolioAnalytics/man/optimize.portfolio.rebalancing.Rd 2013-08-19 19:22:08 UTC (rev 2829)
@@ -8,7 +8,7 @@
rebalance_on = NULL, training_period = NULL,
trailing_periods = NULL)
- optimize.portfolio.rebalancing(R, portfolio,
+ optimize.portfolio.rebalancing(R, portfolio = NULL,
constraints = NULL, objectives = NULL,
optimize_method = c("DEoptim", "random", "ROI"),
search_size = 20000, trace = FALSE, ..., rp = NULL,
Added: pkg/PortfolioAnalytics/man/var.portfolio.Rd
===================================================================
--- pkg/PortfolioAnalytics/man/var.portfolio.Rd (rev 0)
+++ pkg/PortfolioAnalytics/man/var.portfolio.Rd 2013-08-19 19:22:08 UTC (rev 2829)
@@ -0,0 +1,23 @@
+\name{var.portfolio}
+\alias{var.portfolio}
+\title{Calculate portfolio variance}
+\usage{
+ var.portfolio(R, weights)
+}
+\arguments{
+ \item{R}{xts object of asset returns}
+
+ \item{weights}{vector of asset weights}
+}
+\value{
+ numeric value of the portfolio variance
+}
+\description{
+ This function is used to calculate the portfolio variance
+ via a call to constrained_objective when var is an object
+ for mean variance or quadratic utility optimization.
+}
+\author{
+ Ross Bennett
+}
+
More information about the Returnanalytics-commits
mailing list