我正在尝试创建一个代码来运行 Newton Raphson 优化。我正在使用 proc iml,但是当我需要评估错误 (e) 时,我需要总结所有平方差并且不知道如何告诉 SAS 在这种情况下我需要向量分量的总和而不是向量。代码如下:
proc iml; use chap0; read all var{X} into X;
read all var{t} into t;
W=1;
s= exp(X*w)/(1+ exp(X*w)); print s;
e = (s - t) ** 2; /*here I need the result of the sum for that and not the matrix*/
g=2*(s-t)*s*(1-s);
h=2 * s * (1 - s) * (s * (1 - s) + (s - t) * (1 - 2 * s));
count=0;/*init count number*/
do until (e<1e-8);
count=count+1;
w=w0-g/h; /*here I also need the sum of g and h*/
s= exp(X*w)/(1+ exp(X*w));
e = (s - t) ** 2;
wo=w;
end;
谢谢!