Session Ready
Exercise

Optimization with custom moment function

Now we would like to run the optimization using our custom moment function. Recall that the portfolio moments are set in optimize.portfolio() when the moment function is evaluated. We use the custom moment function by passing in the name to the momentFUN argument in optimize.portfolio(). Note how we can use PortfolioAnalytics to easily run optimizations using different methods for estimating moments, which will allow us to evaluate different techniques for moment estimates and refine those estimates by analyzing the optimization results.

Instructions
100 XP

A portfolio specification object, port_spec, and custom moment function, moments_robust(), have already been created for use with this exercise.

  • Run the optimization with the custom moment estimates. Assign this to a variable named opt_custom.
  • Print the output of opt_custom.
  • Run the optimization with sample moment estimates. Assign this to a variable named opt_sample.
  • Print the output of opt_sample.