From: Jess on
Hi,
Could anyone please help me with this portfolio optimization problem: how is it possible to write the function Min. w'*H*w, where H is a covariance matrix of returns and w is a weight vector that has to be optimized. The problem is specifying the matrix H in the function m-file for use in the fmincon function.. Since the m-file does not like any specification of H matrix from a mat file, i'm in a fix. help please?
From: Matt J on
"Jess " <fe09jt(a)mail.wbs.ac.uk> wrote in message <i377ac$4nm$1(a)fred.mathworks.com>...
> Hi,
> Could anyone please help me with this portfolio optimization problem: how is it possible to write the function Min. w'*H*w, where H is a covariance matrix of returns and w is a weight vector that has to be optimized. The problem is specifying the matrix H in the function m-file for use in the fmincon function.. Since the m-file does not like any specification of H matrix from a mat file, i'm in a fix. help please?
==============

I'm skeptical that fmincon is the best tool for this, considering that the objective function is quadratic, but any solution would probably look something like


S=load(YourFile, 'H');
H=S.H;

fmincon(@(w) w'*H*w,... )
From: Alan Weiss on
On 8/2/2010 4:26 PM, Matt J wrote:
> "Jess " <fe09jt(a)mail.wbs.ac.uk> wrote in message
> <i377ac$4nm$1(a)fred.mathworks.com>...
>> Hi,
>> Could anyone please help me with this portfolio optimization problem:
>> how is it possible to write the function Min. w'*H*w, where H is a
>> covariance matrix of returns and w is a weight vector that has to be
>> optimized. The problem is specifying the matrix H in the function
>> m-file for use in the fmincon function.. Since the m-file does not
>> like any specification of H matrix from a mat file, i'm in a fix. help
>> please?
> ==============
>
> I'm skeptical that fmincon is the best tool for this, considering that
> the objective function is quadratic, but any solution would probably
> look something like
>
>
> S=load(YourFile, 'H'); H=S.H;
>
> fmincon(@(w) w'*H*w,... )

As Matt said, you would probably do better to use quadprog:
http://www.mathworks.com/access/helpdesk/help/toolbox/optim/ug/brhkghv-18.html#brhkghv-19

Alan Weiss
MATLAB mathematical toolbox documentation
From: Jess on
Alan Weiss <aweiss(a)mathworks.com> wrote in message <i393o6$c2l$1(a)fred.mathworks.com>...
> On 8/2/2010 4:26 PM, Matt J wrote:
> > "Jess " <fe09jt(a)mail.wbs.ac.uk> wrote in message
> > <i377ac$4nm$1(a)fred.mathworks.com>...
> >> Hi,
> >> Could anyone please help me with this portfolio optimization problem:
> >> how is it possible to write the function Min. w'*H*w, where H is a
> >> covariance matrix of returns and w is a weight vector that has to be
> >> optimized. The problem is specifying the matrix H in the function
> >> m-file for use in the fmincon function.. Since the m-file does not
> >> like any specification of H matrix from a mat file, i'm in a fix. help
> >> please?
> > ==============
> >
> > I'm skeptical that fmincon is the best tool for this, considering that
> > the objective function is quadratic, but any solution would probably
> > look something like
> >
> >
> > S=load(YourFile, 'H'); H=S.H;
> >
> > fmincon(@(w) w'*H*w,... )
>
> As Matt said, you would probably do better to use quadprog:
> http://www.mathworks.com/access/helpdesk/help/toolbox/optim/ug/brhkghv-18.html#brhkghv-19
>
> Alan Weiss
> MATLAB mathematical toolbox documentation


Thank you guys,
I got it with fmincon!!
From: Matt J on
"Jess " <fe09jt(a)mail.wbs.ac.uk> wrote in message <i3hqak$8pr$1(a)fred.mathworks.com>...

>
> Thank you guys,
> I got it with fmincon!!

There was never really any doubt that fmincon would give it to you. There was a chance, however, that quadprog would give it to you faster, depending on your constraints.