Dear all,
I would like to run the following optimization process with IML:
proc optmodel;
var W{1..6};
num MVC{1..6, 1..6} = [0.00111 0.00069 0.00073 0.00053 0.00070 0.00123
0.00069 0.00081 0.00070 0.00043 0.00064 0.00117
0.00073 0.00070 0.00091 0.00050 0.00075 0.00126
0.00053 0.00043 0.00050 0.00133 0.00120 0.00185
0.00070 0.00064 0.00075 0.00120 0.00164 0.00238
0.00123 0.00117 0.00126 0.00185 0.00238 0.00430];
num E{1..6} = [0.00690 0.00360 0.00138 -0.00169 0.00436 -0.01439];
num Var_Rm = 0.001483;
maximize Expected = sum{i in 1..6}W[i]*E[i];
con sum{i in 1..6, j in 1..6}W[i]*MVC[i,j]*W[j] = Var_Rm;
con BUDGET: sum{i in 1..6}W[i] = 1;
solve; print W;
quit;
Ideally something simple in a first time like:
proc iml;
MVC = { 0.00111 0.00069 0.00073 0.00053 0.00070 0.00123
0.00069 0.00081 0.00070 0.00043 0.00064 0.00117
0.00073 0.00070 0.00091 0.00050 0.00075 0.00126
0.00053 0.00043 0.00050 0.00133 0.00120 0.00185
0.00070 0.00064 0.00075 0.00120 0.00164 0.00238
0.00123 0.00117 0.00126 0.00185 0.00238 0.00430 };
e = { 0.00690 0.00360 0.00138 -0.00169 0.00436 -0.01439 }
Var_Rm = { 0.001483 };
start max(w);
w = p`; /* Transpose w into a colum vector, the NLP routines passing in a row vector as the parameter */
return e * w;
finish;
/* specify linear constraints ???? */
con w` * MVC * w = Var_Rm;
con sum(w) = 1;
w0 = {0.17 0.17 0.17 0.17 0.17 0.15};
optn = { ?????? }
call nlpnra(rc, w_Opt, "max", w0, optn, con);
maxVal = max(w_Opt);
print w_Opt;
quit;
Thank you in advance for any help,
The constraint on the variance is not a linear constraint. It is quadratic. Therefore, you have to use a user-defined function module for that constraint. You can use a GLOBAL clause for the MVC and Var_Rm parameters and compute the constraint as
conVar = w * MVC * w` - Var_Rm; /* constrain this eqn to 0 */
Because you have a nonlinear constraint, you need to use the NLPQN (quasi-Newton) method instead of the Newton-Raphson function in your original post.
The SAS/IML documentation has a four-parameter example that is similar to your six-parameter problem. See the Getting Started example for the "Rosen-Suzuki Problem."
In addition to the linear constraint sum(w)=1, you should also specify the bounds 0 <= w[i] <= 1.
@Rick_SAS already gave you an example , in IML there is an build-in function can solve this kind of question.
Or check my paper :
"Get Tangency Portfolio by SAS/IML"
http://support.sas.com/resources/papers/proceedings17/0997-2017.pdf
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.
Find more tutorials on the SAS Users YouTube channel.