Message Boards Message Boards

Portfolio Optimization - FindMinimum vs NMinimize

I was putting together a notebook for portfolio optimization (classical Markowitz) and found that the results were slightly different than I was getting with Excel's Solver. I'd prefer to use Mathematica for this since it is much easier, especially for large examples. I have attached a notebook that shows what I am talking about.

Initially, I was using NMinimize, but I later tried FindMinimum and found it to be much faster. However, FindMinimum was giving slightly different answers than NMinimize for the optimal weights. I explored this further and found (I think) that FindMinimum is more accurate, which surprised me. Here is a table that shows the calculated weights for the 4 stocks:

enter image description here

The differences here are quite small, but for another dataset one of them is different by about 2% (e.g. 15% vs 17% weight).

For the example in the attached notebook, you can see that the portfolio weights sum to 1 with FindMinimum, but not with NMinimize. Further, the portfolio return is exactly equal to the target return (1% monthly) with FindMinimum, but not with NMinimize. These results hold for a different (and larger) dataset.

I think that the attached notebook is well-documented and should be easy to follow. I guess my question is why are these two functions giving different results? Am I right to trust FindMinimum over NMinimize, or have I made some kind of mistake?

Thanks,

Tim

Attachments:
POSTED BY: Tim Mayes
3 Replies

The differences you report are within the default accuracies of the two methods.

POSTED BY: Frank Kampas

Ok, thanks. They are certainly close enough, especially for my purposes. I was just surprised that they were different.

Tim

POSTED BY: Tim Mayes

If you raise the Precision and Accuracy goals in the calculations, the results will be closer together.

POSTED BY: Frank Kampas
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract