[R-SIG-Finance] comparing solve.pq and nloptr for min variance portfolio

Alec Schmidt aschmid1 at stevens.edu
Fri Mar 18 16:32:10 CET 2016


Enrico,
Here we're. I attach two scripts: one for solve.pq, another for nloptr. Both run with the same input file and print output on the screen.

Thanks again, Alec
________________________________________
From: Enrico Schumann <es at enricoschumann.net>
Sent: Friday, March 18, 2016 11:08 AM
To: Alec Schmidt
Cc: R-SIG-Finance at r-project.org
Subject: Re: [R-SIG-Finance] comparing solve.pq and nloptr for min variance portfolio

On Fri, 18 Mar 2016, Alec Schmidt <aschmid1 at stevens.edu> writes:

> Hi Enrico,
> Many thanks for your interest. I attach my script and input file with
> asset tickers. Sorry for lots of unrelated stuff - it's a working
> draft.
>
> Alec

Thanks for sending the script, Alec. But you will need to
simplify it if people are to help you. [My bad: I should have
said _minimal_ reproducible example:
https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example
]



> ________________________________________
> From: Enrico Schumann <es at enricoschumann.net>
> Sent: Friday, March 18, 2016 10:25 AM
> To: Alec Schmidt
> Cc: R-SIG-Finance at r-project.org
> Subject: Re: [R-SIG-Finance] comparing solve.pq and nloptr for min variance portfolio
>
> On Fri, 18 Mar 2016, Alec Schmidt <aschmid1 at stevens.edu> writes:
>
>> I'm puzzled that I cannot reproduce results for asset weights using
>> solve.pq and nloptr even in the case of just three assets.  E.g. if I
>> use NLOPT_LD_SLSQP and start with initial weights of 1/3, I may obtain
>> (0.47, 0, 0.53) vs (0.52, 0, 0.47).  If I start with (0.52, 0, 0.47),
>> I do get (0.52, 0, 0.47)...
>>
>> When I use NLOPT_GN_ISRES or other nloptr solvers that permit equality
>> constraint sum(weights)=1 with initial weights of 1/3, I obtain
>> (almost) the same initial weights after 20000 iterations with
>> xtol_rel=1.0e-8...
>>
>> I remember from my MC simulations of protein structures (20 years ago)
>> that sampling is key due to multiple local minimums but is it so bad
>> for a simple portfolio?
>>
>>
>> I'll greatly appreciate relevant comments.
>>
>> Alec
>
> [...]
>
> Unless your covariance matrix is 'broken' in some way, a
> minimum-variance portfolio with only a budget constraint should be
> fairly easy to compute (no multiple local minima, smooth objective
> function, ...). Please provide a reproducible example.
>
> Kind regards,
>         Enrico

--
Enrico Schumann
Lucerne, Switzerland
http://enricoschumann.net
-------------- next part --------------
A non-text attachment was scrubbed...
Name: solve.pq_portfolio.R
Type: application/octet-stream
Size: 3193 bytes
Desc: solve.pq_portfolio.R
URL: <https://stat.ethz.ch/pipermail/r-sig-finance/attachments/20160318/11bac887/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: nloptr_portfolio.R
Type: application/octet-stream
Size: 2934 bytes
Desc: nloptr_portfolio.R
URL: <https://stat.ethz.ch/pipermail/r-sig-finance/attachments/20160318/11bac887/attachment-0001.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: SPYETF3.csv
Type: application/vnd.ms-excel
Size: 75 bytes
Desc: SPYETF3.csv
URL: <https://stat.ethz.ch/pipermail/r-sig-finance/attachments/20160318/11bac887/attachment.xlb>


More information about the R-SIG-Finance mailing list