Analyzing optimization results
1. Analyzing optimization results
The PortfolioAnalytics package includes several functions for visualization and data extraction of the optimization results.2. Workflow: analyze results
The analysis is very important to understand and develop intuition of the portfolio optimization problem. The visualization and extraction functions are designed to work independent of the chosen solver despite differences of each solver. The table in this slide lists the functions for visualizing the results of the optimization and extracting important data from the optimization results. These functions will chart or return the data regardless of the solver used so you do not necessarily need to know the details of the output returned from each solver. The extract functions are useful if you want to return the data as an xts object or data frame for further analysis or display in a table. For visualizing the output of the optimization, you should use the chart functions. The next slides will demonstrate a few of these functions.3. Example: extract weights
In what follows, we'll go through a few functions for analyzing results of a single period optimization and an optimization with period rebalancing. In this example, the opt object is the output from optimize-dot-portfolio4. Example: extract weights
and the opt_rebal object is the output from optimize-dot-portfolio-dot-rebalancing. Note that you use the same function to extract the optimal weights from both optimization output objects.5. Example: extract weights
In the case of the single period optimization, only a single set of weights is returned.6. Example: extract weights
However, for the case of optimization with rebalancing, the optimal weights at each rebalancing period are returned. Head with n equals 3 is used to only display the first 3 observations here.7. Example: chart weights
You can visualize the optimal weights with the char-dot-Weights function. Just like extracting the weights, you use the same function for charting the weights of a single period optimization or optimization with rebalancing. The optimal weights for each optimization are plotted with the chart-dot-Weights function. Notice that for the case of the single period optimization, only a single set of weights is plotted.8. Example: chart weights
However, a time series of optimal weights at each rebalancing period is plotted for the backtest. Extracting the objective measures works the same way as the optimal weights.9. Example: extract objective measures
The objective measures are the values of the objectives of the optimal portfolio. In this case, you have one objective in the portfolio specification, to minimize portfolio standard deviation. The intuition is that this is the minimum value of the objective found by the optimization. You can see the objective value of the optimal portfolio for the single period optimization as well as a time series of the objective values at each rebalancing period for the optimization with annual rebalancing.10. Example: optimization analysis
You can compute the returns of the portfolio with the Return-dot-portfolio function. You need to pass in the asset returns and the optimal weights at each rebalancing period, which you get with the extractWeights function. You can then visualize the portfolio returns with the charts-dot-PerformanceSummary function. The first panel displays the cumulative returns, the second panel is a bar plot of the returns for each period, and the third panel displays the drawdowns. A drawdown occurs any time the cumulative return falls below the maximum cumulative return.11. Let's practice!
Let's move on to a few exercises.Create Your Free Account
or
By continuing, you accept our Terms of Use, our Privacy Policy and that your data is stored in the USA.