optimize_statfolio: Optimize a portfolio of assets N times to get asset weight...

Description Usage Arguments Details Value See Also

View source: R/optimize_statfolio.R


Optimze a portfolio of assets N times in order to gather statistics on the portfolio asset weights. The optimization is performed at the most recent date as provided by the xts matrix of returns.


optimize_statfolio(rets, portfolio, train_window = 63, N = 1,
  weightFUN = "mean", maxwtsmat = NA, optimize_method = "DEoptim",
  seed = 1, ...)



An xts matrix of asset returns.


An object of type "portfolio" specifying the constraints and objective function.


The training window (in days) used to subset rets to calculate the optimization matrix. This is normally the same as the rolling_window if WFO optimization is used.


The number of times to repeatedly call function optimize.portfolio to generate weight statistics. Default is 1.


Sets the method used to compute the asset weights returned from N multiple runs of optimize.portfolio. Default is "mean", but it can be any valid function name such as "median".


The maximum weights xts matrix. It should include a row with the current optimization date, which will be extracted as a vector and added as a constraint in the optimize.portfolio function call. If the maximum weights are NOT a function of the date, then this can be specified as a named vector. Ignored if not specified.


Sets the optimization method used by optimize.portfolio. Default is "DEoptim".


The random seed used to make a model reproducible.


Additional arguments passed through to optimize.portfolio.


The feature matrix passed to the custom objective function, if specified, used by optimize.portfolio. NOT USED


This function leverages the optimize.portfolio function from package PortfolioAnalytics. It differs from optimize.portfolio in several ways. First, an argument N is provided to repeatedly call optimize.portfolio in order to gather statistics on the asset weights. This is relevant because often, the optimization of the objective function results in a somewhat unstable optimum, resulting in many possible asset weights.

See the vignette xtsanalytics for more details on the statfolio data structure.


Returns a list containing the same elements as what optimize.portfolio normally returns, with the following exceptions:


A named vector containing the optimal set of weights for the portfolio. If N > 1, then this is a statistic computed from all optimize.portfolio runs. The choice of statistic is a function named using argument weightFUN. Default is "mean".


The number of times function optimize.portfolio was called.


A matrix containing the optimized asset weights for each run of optimize.portfolio


A named vector containing the standard deviations of the weight values, computed by taking the StdDev of $allweights. If N = 1, then this will be all zeroes.

See Also


jeanmarcgp/ResilientPortfolio documentation built on April 8, 2018, 5:43 p.m.