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

say I have a function f(x,y)=x+y, and the data set is given by

var

3

6

5

7

Now I want to minimize the the function (x+y-3)^2+(x+y-6)^2+(x+y-5)^2+(x+y-7)^2 with the constraints  0<x<5, 0<y<5.

 

I know the proc fcmp can be used to define a function like (x+y-3)^2, and optimize it under some constrains, but not sure how to use it on the whole column, any hints? Thanks.

 

1 ACCEPTED SOLUTION

Accepted Solutions
liyongkai800
Obsidian | Level 7

The program is pretty much like this, and you may need to adjust the initial values (in parms statement) if the hessian matrix is singular. 

 

proc nlin data=whatever method=marquardt;
parms x1=1 x2=0 to by 0.1;  
bounds x1>=0;
model y=f(x1,x2);
output out=b predicted=yp;
run;

View solution in original post

4 REPLIES 4
PeterClemmensen
Tourmaline | Level 20

How does the value var relate to the function you want to minimize?

 

PROC NLIN would be my first choice

liyongkai800
Obsidian | Level 7
It seems PROC NLIN can estimate the parameters of the model directly, therefore I don't need to construct the function by myself. Thanks for the hint, I will give a try.
PeterClemmensen
Tourmaline | Level 20
Anytime, glad to help 🙂

Let me know how it goes and please post the final code here for other users to benefit from.
liyongkai800
Obsidian | Level 7

The program is pretty much like this, and you may need to adjust the initial values (in parms statement) if the hessian matrix is singular. 

 

proc nlin data=whatever method=marquardt;
parms x1=1 x2=0 to by 0.1;  
bounds x1>=0;
model y=f(x1,x2);
output out=b predicted=yp;
run;

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1406 views
  • 4 likes
  • 2 in conversation