[Returnanalytics-commits] r2626 - in pkg/PortfolioAnalytics: . R man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue Jul 23 01:56:57 CEST 2013
Author: rossbennett34
Date: 2013-07-23 01:56:57 +0200 (Tue, 23 Jul 2013)
New Revision: 2626
Added:
pkg/PortfolioAnalytics/man/constrained_objective_v1.Rd
Modified:
pkg/PortfolioAnalytics/NAMESPACE
pkg/PortfolioAnalytics/R/constrained_objective.R
pkg/PortfolioAnalytics/man/constrained_objective.Rd
Log:
alias _v2 of constrained_objective and add _v1 to old constrained_objective
Modified: pkg/PortfolioAnalytics/NAMESPACE
===================================================================
--- pkg/PortfolioAnalytics/NAMESPACE 2013-07-22 23:51:40 UTC (rev 2625)
+++ pkg/PortfolioAnalytics/NAMESPACE 2013-07-22 23:56:57 UTC (rev 2626)
@@ -10,8 +10,8 @@
export(charts.DE)
export(charts.RP)
export(constrained_group_tmp)
+export(constrained_objective_v1)
export(constrained_objective_v2)
-export(constrained_objective)
export(constraint_ROI)
export(constraint_v2)
export(constraint)
Modified: pkg/PortfolioAnalytics/R/constrained_objective.R
===================================================================
--- pkg/PortfolioAnalytics/R/constrained_objective.R 2013-07-22 23:51:40 UTC (rev 2625)
+++ pkg/PortfolioAnalytics/R/constrained_objective.R 2013-07-22 23:56:57 UTC (rev 2626)
@@ -62,7 +62,7 @@
#' @seealso \code{\link{constraint}}, \code{\link{objective}}, \code{\link[DEoptim]{DEoptim.control}}
#' @author Kris Boudt, Peter Carl, Brian G. Peterson
#' @export
-constrained_objective <- function(w, R, constraints, ..., trace=FALSE, normalize=TRUE, storage=FALSE)
+constrained_objective_v1 <- function(w, R, constraints, ..., trace=FALSE, normalize=TRUE, storage=FALSE)
{
if (ncol(R)>length(w)) {
R=R[,1:length(w)]
@@ -382,6 +382,8 @@
#' @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, Ross Bennett
+#' @aliases constrained_objective
+#' @rdname constrained_objective
#' @export
constrained_objective_v2 <- function(w, R, portfolio, ..., trace=FALSE, normalize=TRUE, storage=FALSE)
{
@@ -715,3 +717,5 @@
return(list(out=as.numeric(out), weights=w, objective_measures=tmp_return))
}
}
+
+constrained_objective <- constrained_objective_v1
\ No newline at end of file
Modified: pkg/PortfolioAnalytics/man/constrained_objective.Rd
===================================================================
--- pkg/PortfolioAnalytics/man/constrained_objective.Rd 2013-07-22 23:51:40 UTC (rev 2625)
+++ pkg/PortfolioAnalytics/man/constrained_objective.Rd 2013-07-22 23:56:57 UTC (rev 2626)
@@ -1,8 +1,9 @@
-\name{constrained_objective}
+\name{constrained_objective_v2}
\alias{constrained_objective}
-\title{function to calculate a numeric return value for a portfolio based on a set of constraints}
+\alias{constrained_objective_v2}
+\title{constrained_objective_v2 2 function to calculate a numeric return value for a portfolio based on a set of constraints and objectives}
\usage{
- constrained_objective(w, R, constraints, ...,
+ constrained_objective_v2(w, R, portfolio, ...,
trace = FALSE, normalize = TRUE, storage = FALSE)
}
\arguments{
@@ -11,8 +12,8 @@
\item{w}{a vector of weights to test}
- \item{constraints}{an object of type "constraints"
- specifying the constraints for the optimization, see
+ \item{portfolio}{an object of type "portfolio" specifying
+ the constraints and objectives for the optimization, see
\code{\link{constraint}}}
\item{\dots}{any other passthru parameters}
@@ -84,7 +85,7 @@
via \dots
}
\author{
- Kris Boudt, Peter Carl, Brian G. Peterson
+ Kris Boudt, Peter Carl, Brian G. Peterson, Ross Bennett
}
\seealso{
\code{\link{constraint}}, \code{\link{objective}},
Added: pkg/PortfolioAnalytics/man/constrained_objective_v1.Rd
===================================================================
--- pkg/PortfolioAnalytics/man/constrained_objective_v1.Rd (rev 0)
+++ pkg/PortfolioAnalytics/man/constrained_objective_v1.Rd 2013-07-22 23:56:57 UTC (rev 2626)
@@ -0,0 +1,93 @@
+\name{constrained_objective_v1}
+\alias{constrained_objective_v1}
+\title{function to calculate a numeric return value for a portfolio based on a set of constraints}
+\usage{
+ constrained_objective_v1(w, R, constraints, ...,
+ trace = FALSE, normalize = TRUE, storage = FALSE)
+}
+\arguments{
+ \item{R}{an xts, vector, matrix, data frame, timeSeries
+ or zoo object of asset returns}
+
+ \item{w}{a vector of weights to test}
+
+ \item{constraints}{an object of type "constraints"
+ specifying the constraints for the optimization, see
+ \code{\link{constraint}}}
+
+ \item{\dots}{any other passthru parameters}
+
+ \item{trace}{TRUE/FALSE whether to include debugging and
+ additional detail in the output list}
+
+ \item{normalize}{TRUE/FALSE whether to normalize results
+ to min/max sum (TRUE), or let the optimizer penalize
+ portfolios that do not conform (FALSE)}
+
+ \item{storage}{TRUE/FALSE default TRUE for DEoptim with
+ trace, otherwise FALSE. not typically user-called}
+}
+\description{
+ 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
+}
+\details{
+ 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
+}
+\author{
+ Kris Boudt, Peter Carl, Brian G. Peterson
+}
+\seealso{
+ \code{\link{constraint}}, \code{\link{objective}},
+ \code{\link[DEoptim]{DEoptim.control}}
+}
+
More information about the Returnanalytics-commits
mailing list