BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
degdeg
Calcite | Level 5

Hello,

 

I need to minimize this function A = w' * cov * w, where cov is my variance matrix 5x5 and w is my list of parameters i need to chose in order to minimize A so w is a vector 1x5.

 

I have constraints where the sum of w = 1 and the parameters of w need to be between 0 and 1.

 

I tried several things but I am a bit lost on IML to do that, if somebody can help me, I have read the SAS IML User Guide with the routine function and some other topics but I didn't really understand completely how to suceed in order to solve my problem.

 

Thanks you by advance.

 

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

 If w* is the value that minimizes w`*A*w, then w* also minimizes alpha * w`*A*w for all alpha > 0.

 

If you think back to calculus, you might remember the 1-D analogy: the value of x that minimizes 3(x-2)^2 also minimizes alpha 3(x-2)^2 for all alpha > 0. 

View solution in original post

3 REPLIES 3
Rick_SAS
SAS Super FREQ

Q(w) = w`*A*w is a quadratic function of w. You can use the NLPQUA subroutine to solve this problem, including putting constraints on the parameters. See the article "Quadratic optimization in SAS" for an example and discussion.

degdeg
Calcite | Level 5

Thanks you !

 

So I tried this :

 

w = J(5,1,0.2);
con = {0 0 0 0 0 . . ,
1 1 1 1 1 . . ,
1 1 1 1 1 0 1};
opt = {0 2};

 

CALL NLPQUA(rc,wres,nccov,w,opt,con);

 

And it worked but I'm not sure If it gives me the right wres vector solution of the minimization of w'*A*w where A is nccov.

 

Instead it gives me the minimization of 0.5*w'*A*w I think, isn't it ?

 

Thanks you again by advance.

Rick_SAS
SAS Super FREQ

 If w* is the value that minimizes w`*A*w, then w* also minimizes alpha * w`*A*w for all alpha > 0.

 

If you think back to calculus, you might remember the 1-D analogy: the value of x that minimizes 3(x-2)^2 also minimizes alpha 3(x-2)^2 for all alpha > 0. 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

Multiple Linear Regression in SAS

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.

From The DO Loop
Want more? Visit our blog for more articles like these.
Discussion stats
  • 3 replies
  • 965 views
  • 0 likes
  • 2 in conversation