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;

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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