Hello everyone, While still practicing with proc optmodel, I tried to build a simple portfolio where each asset contributes equally to the portfolio risk. The risk contribution (RC) of an asset depending on its weight, the problem is endogeneous. The authors of this methodology recommend to use a sequential quadratic programming algorithm and minimize the total squared differences between the RC of all pairs of assets. Everything is wrote here after in IML (optimal weights were found using Excel Solver), but my PROC OPTMODEL does not work. Perhaps the problem comes from the fact that the optimal solution W is not directly in the objective function? proc iml;
MVC = {0.0225 0.015 0 -.0015, 0.015 0.04 0.012 0.008,
0 0.012 0.09 0.021, -.0015 0.008 0.021 0.01};
W = {0.31337624982391 0.174869881146739 0.130532835089507 0.381221033939844}; /* Results from Excel solver */
RC = W` # ((MVC * W`) / sqrt(W * MVC * W`)); print RC;
/* Risk Contribution of the 1st Asset */
i = 1;
Element1 = MVC[i,1]*W[,1] + MVC[i,2]*W[,2] + MVC[i,3]*W[,3] + MVC[i,4]*W[,4];
Var1 = W[,1]*MVC[1,1]*W[,1] + W[,1]*MVC[1,2]*W[,2] + W[,1]*MVC[1,3]*W[,3] + W[,1]*MVC[1,4]*W[,4]
+ W[,2]*MVC[2,1]*W[,1] + W[,2]*MVC[2,2]*W[,2] + W[,2]*MVC[2,3]*W[,3] + W[,2]*MVC[2,4]*W[,4]
+ W[,3]*MVC[3,1]*W[,1] + W[,3]*MVC[3,2]*W[,2] + W[,3]*MVC[3,3]*W[,3] + W[,3]*MVC[3,4]*W[,4]
+ W[,4]*MVC[4,1]*W[,1] + W[,4]*MVC[4,2]*W[,2] + W[,4]*MVC[4,3]*W[,3] + W[,4]*MVC[4,4]*W[,4];
RC1 = W[,i] * ((Element1) / sqrt(Var1)); print RC1;
/* Objective function */
f = (RC[1,]-RC[2,])##2 + (RC[1,]-RC[3,])##2 + (RC[1,]-RC[4,])##2
+ (RC[2,]-RC[1,])##2 + (RC[2,]-RC[3,])##2 + (RC[2,]-RC[4,])##2
+ (RC[3,]-RC[1,])##2 + (RC[3,]-RC[2,])##2 + (RC[3,]-RC[4,])##2
+ (RC[4,]-RC[1,])##2 + (RC[4,]-RC[2,])##2 + (RC[4,]-RC[3,])##2;
/* Sanity check */
RC2 = sqrt(W * MVC * W`)/ncol(MVC);
/* RC of each asset should be equal to portfolio risk divided by the number of assets */
quit;
proc optmodel ;
/* Declare the variable */
var W{1..4} >= 0; /* Long-only constraint */
/* Populate the model by reading in the specific data instance */
number MVC{1..4, 1..4} = [0.0225 0.015 0 -.0015
0.015 0.04 0.012 0.008
0 0.012 0.09 0.021
-.0015 0.008 0.021 0.01];
number RC{1..4}; for {k in 1..4} RC[k] = sum{i in 1..4, j in 1..4}W[k] * ((MVC[k,j]*W[j]) / sqrt(W[i]*MVC[i,j]*W[j]));
/* Minimize the objective function (total squared differences between the RC of all pairs of assets) */
minimize f = sum{i in 1..4}(RC[i] - RC[i])^2;
/* Subject to the following constraints */
con BUDGET: sum{i in 1..4}W[i] = 1;
/* Starting points */
W[1] = 0.25; W[2] = 0.25; W[3] = 0.25; W[4] = 0.25;
solve with sqp;
print W;
quit; Could you please help me make it work, and how could I replace the starting points (equal weights) with something more generic like: for {i in 1..4} W[i] = 1/_N_ Thank you very much in advance for your help,
... View more