Hi All,
I have just started with Matlab, and struggle with the following problem -
optimization of 3-assets portfolio:
ExpRet = [0.1 0.2 0.15];
ExpCov = [0.005 -0.010 0.004; -0.010 0.040 -0.002; 0.004 -0.002 0.023];
%My goal is to minimize the function for portfolio variance (saved in Weights.m):
function [Weights] = f(w,ExpCov)
Weights = w'*ExpCov*w
%I believe my problem lies in the objective function
%Given:
ExpRet = [0.1 0.2 0.15];
ExpCov = [0.005 -0.010 0.004; -0.010 0.040 -0.002; 0.004 -0.002 0.023];
TargetReturn=0.15;
X0=zeros(3,1);
Aeq = [ExpRet;ones(1,3)];
Beq = [TargetReturn;1];
LB = zeros(3,1);
UB = ones(3,1);
[OptimalWeights, OptimalVariance] = fmincon(@Weights,X0,[],[],Aeq,Beq,LB,UB);
I would be extremely grateful for your insight.
|
|
0
|
|
|
|
Reply
|
ADam
|
1/25/2010 10:27:05 PM |
|
ADam Skoczynski wrote:
> Hi All, I have just started with Matlab, and struggle with the following
> problem -
> optimization of 3-assets portfolio:
>
> ExpRet = [0.1 0.2 0.15];
> ExpCov = [0.005 -0.010 0.004; -0.010 0.040 -0.002; 0.004 -0.002
> 0.023];
>
> %My goal is to minimize the function for portfolio variance (saved in
> Weights.m):
> function [Weights] = f(w,ExpCov)
> Weights = w'*ExpCov*w
> %I believe my problem lies in the objective function
>
> %Given:
> ExpRet = [0.1 0.2 0.15];
> ExpCov = [0.005 -0.010 0.004; -0.010 0.040 -0.002; 0.004 -0.002
> 0.023];
> TargetReturn=0.15;
> X0=zeros(3,1);
> Aeq = [ExpRet;ones(1,3)];
> Beq = [TargetReturn;1];
> LB = zeros(3,1); UB = ones(3,1);
> [OptimalWeights, OptimalVariance] =
> fmincon(@Weights,X0,[],[],Aeq,Beq,LB,UB);
>
> I would be extremely grateful for your insight.
There are several answers to your question.
1. You are correct in believing you did not write the objective function
correctly. Take a look at the documentation, or at least an example
where it is done correctly.
http://www.mathworks.com/access/helpdesk/help/toolbox/optim/ug/brhkghv-3.html
http://www.mathworks.com/access/helpdesk/help/toolbox/optim/ug/brn4nh7.html
To pass the ExpCov parameters, see
http://www.mathworks.com/access/helpdesk/help/toolbox/optim/ug/brhkghv-7.html
1a. Short answer:
Weights = @(w)w'*ExpCov*w;
Pass this form of the function without an @ sign (I mean the syntax is
fmincon(Weights,X0,...))
2. You should probably use quadprog instead of fmincon:
http://www.mathworks.com/access/helpdesk/help/toolbox/optim/ug/brhkghv-18.html#brhkghv-19
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation
|
|
0
|
|
|
|
Reply
|
Alan
|
1/26/2010 12:55:31 PM
|
|
|
1 Replies
1353 Views
(page loaded in 0.028 seconds)
Similiar Articles: Mean Variance optimization with FMINCON - comp.soft-sys.matlab ...Hi All, I have just started with Matlab, and struggle with the following problem - optimization of 3-assets portfolio: ExpRet = [0.1 0.2 0.15... Portfolio optimization using minimum-variance (fmincon) - comp ...Mean Variance optimization with FMINCON - comp.soft-sys.matlab ..... fmincon - comp.soft-sys.matlab > > > > I have rescaled the problem so fmincon inputs (mean, s.d.1, s ... rescaling for fmincon - comp.soft-sys.matlabhow can I do integer optimization with GA in Matlab? - comp.soft ... Mean Variance optimization with FMINCON - comp.soft-sys.matlab ..... comp.soft-sys.matlab optimization ... exemple Fmincon - comp.soft-sys.matlabMean Variance optimization with FMINCON - comp.soft-sys.matlab ... Take a look at the documentation, or at least an example where it is done correctly. ... svd and variance - comp.soft-sys.matlabError using fmincon - comp.soft-sys.matlab Zitierten Text ausblenden - > > - Zitierten Text anzeigen - Use singular-value decomposition ... Mean Variance optimization with ... mean ,variance,standard deviation ,kurtosis of image - comp.soft ...Mean Variance optimization with FMINCON - comp.soft-sys.matlab ... compute standard deviation of lsqnonlin estimates? - comp.soft-sys ... mean ,variance,standard deviation ... Error using fmincon - comp.soft-sys.matlabMean Variance optimization with FMINCON - comp.soft-sys.matlab ... Basically, I use mean square error as my output of my fitness ... Portfolio optimization using minimum ... mean, variance of an image - comp.soft-sys.matlabMean Variance optimization with FMINCON - comp.soft-sys.matlab ... mean, variance of an image - comp.soft-sys.matlab Mean Variance optimization with FMINCON - comp.soft ... GARCH(1,1) - Matlab - comp.soft-sys.matlabMean Variance optimization with FMINCON - comp.soft-sys.matlab ... GARCH(1,1) MLE Question - comp.soft-sys.matlab Mean Variance optimization with FMINCON - comp.soft-sys ... NN optimization using GA - Fitness Function - comp.soft-sys.matlab ...Mean Variance optimization with FMINCON - comp.soft-sys.matlab ... NN optimization using GA - Fitness Function - comp.soft-sys.matlab ... Basically, I use mean square ... Mean Variance optimization with FMINCON - comp.soft-sys.matlab ...Hi All, I have just started with Matlab, and struggle with the following problem - optimization of 3-assets portfolio: ExpRet = [0.1 0.2 0.15... Mean Variance optimization with FMINCON - Newsreader - MATLAB CentralHi All, I have just started with Matlab, and struggle with the following problem - optimization of 3-assets portfolio: ExpRet = [0.1 0.2 0.15]; 7/23/2012 4:15:29 AM
|