KP4711
KP4711

Reputation: 37

Matlab: fmincon, Portfolio Optimization, difficulties with free variables

i´m trying to replicate a paper ("Is the marketporfolio mean-variance efficient after all?" from Levy & Roll) in Matlab. I want to minimize the following function (D) with its constraints:

Objective function

Constraints

I want to get mu and sigma,

furthermore alpha, q and r_z are free variables, where

I have:

Now i don´t know how to handle the free variables alpha, q and r_z

My objective function D :

function dist=distOpt(alpha, N, x0, mu_sam, sigma_sam)

sumSigma=0; 

for i=1:N 
       sumMu=sumMu+((x0(i)-mu_sam(i))/sigma_sam(i))^2; 
       sumSigma=sumSigma+((x0(N+i)-sigma_sam(i))/sigma_sam(i))^2; 
end
dist=sqrt(alpha*(1/N)*sumMu + (1-alpha)*(1/N)*sumSigma);

And constraints:

Mu_sam=repelem(-0.0001,y-1);
 Sigma_sam=repelem(-0.0002,y-1);     
 x0=[Mu_sam Sigma_sam];

function [c,ceq] = confuneq(x0,rz,Cor,Weights)
q=1;

ceq=diag(x0(7:end))*Cor*diag(x0(7:end))*Weights' - q*(x0(1:6)'-rz);
c=[];

My use of fmincon:

optFunc=@(x0) distOpt(alpha,(y-1),x0, Mu_sam, Sig_sam); 
 options = optimoptions(@fmincon,'Algorithm','sqp','MaxFunctionEvaluations', 12000,'FunValCheck','on');
 nonlcon=@(c,ceq) confuneq(x0,r_z, rho, Weights);
 [x0, fval, exitFlag]= fmincon(optFunc,x0,[],[],[],[],[],[],nonlcon,options);       

Can anyone help?

Upvotes: 0

Views: 451

Answers (1)

DasMoeh
DasMoeh

Reputation: 411

Now i don´t know how to handle the free variables alpha, q and r_z

I think you have two options:

1) Choose fix values for them.

2) Include them into your x to get optimal values.

Upvotes: 0

Related Questions