3

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.

DomPazz
  • 12,415
  • 17
  • 23
Jordak
  • 217
  • 2
  • 9

1 Answers1

3

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
DomPazz
  • 12,415
  • 17
  • 23
  • Alas, I don't have access to SAS/OR. If that's the only/best way to do this then I'll look into getting it, but for the moment do you have any other thoughts? – Jordak Jun 18 '14 at 14:40
  • PROC MODEL in SAS/ETS can also fit this. The problem is getting starting values that will make it converge. Do you have SAS/ETS and/or SAS/IML? – DomPazz Jun 21 '14 at 19:38
  • I actually discovered I do have remote access to SAS/OR, and OPTMODEL is doing great. Thanks for your help! – Jordak Jun 23 '14 at 14:38
  • Glad to help. If you need regression diagnostics, take the values from OPTMODEL and put them into PROC MODEL as starting values. MODEL will converge almost instantaneously and give you all the regression stats you expect. – DomPazz Jun 23 '14 at 14:43