Reputation: 217
I have a data set with variables y, x1, and x2. I want to find an equation that fits the model:
y = k1*x1c1 + k2*x2c2
by finding k1, c1, k2, and c2. How do I do this in SAS? Specifically if there is an easy way in SAS Enterprise Guide, that's preferable.
Upvotes: 3
Views: 746
Reputation: 12465
First, there is no WYSIWYG in EG that I know of to do this.
You can use a number of procedures, getting them to converge (PROC MODEL comes to mind as a likely candidate) is not easy. I used PROC OPTMODEL from SAS/OR in this example.
data test;
do i=1 to 1000;
x1 = rannor(123)*10 + 100;
x2 = rannor(123)*2 + 10;
y = 10*(x1**2) + -10*(X2**3) + rannor(123);
output;
end;
run;
proc optmodel;
num n=1000;
set<num> indx;
num y{indx}, x1{indx}, x2{indx};
read data test into indx=[_N_] y x1 x2;
var k1 init 1000,
k2 init 1000,
c1 init 1 ,
c2 init 1 ,
mean init 0;
min sse = sum{i in indx}( (y[i]-(k1*x1[i]**c1 + k2*x2[i]**c2))**2 );
solve with nlp / maxiter=1000 ms;
print k1 k2 c1 c2;
quit;
Produces:
The OPTMODEL Procedure
Solution Summary
Solver Multistart NLP
Algorithm Interior Point
Objective Function sse
Solution Status Best Feasible
Objective Value 976.35152997
Number of Starts 100
Number of Sample Points 2560
Number of Distinct Optima 78
Random Seed Used 18410
Optimality Error 0.0049799881
Infeasibility 0
k1 k2 c1 c2
9.9999 -9.9993 2 3
Upvotes: 3