我的数据集包含变量y,x 1 和x 2 。我想找到一个适合模型的方程式:
y = k 1 * x 1 c 1 + k 2 * X <子> 2 子> C <子> 2 子>
通过找到k 1 ,c 1 ,k 2 和c 2 。我如何在SAS中执行此操作?特别是如果SAS Enterprise Guide中有一种简单的方法,那就更好了。
答案 0 :(得分: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