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.

4

1 回答 1

3

首先,据我所知,EG 中没有 WYSIWYG 可以做到这一点。

您可以使用许多过程,但要让它们收敛(PROC MODEL 可能是一个候选者)并不容易。在这个例子中,我使用了来自 SAS/OR 的 PROC OPTMODEL。

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;

产生:

                    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
于 2014-06-18T02:04:14.083 回答