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.
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;
How does the value var relate to the function you want to minimize?
PROC NLIN would be my first choice
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;
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!
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.
Ready to level-up your skills? Choose your own adventure.