5

Is there any way to get the Hessian matrix in the proc logistic in SAS? Or which will be an option to calculated it taking from departure the proc logsitic?

I have been reading the function documentation but cannot see that there is a way to include it in the output tables.

Amir
  • 10,600
  • 9
  • 48
  • 75
user1571823
  • 394
  • 5
  • 20
  • Adding [tag:SAS-iml] in case one of the iml folks knows the answer. You might want to look at [this SAS newsgroup question](http://compgroups.net/comp.soft-sys.sas/hessian-and-scores-in-the-logistic-proc/661329) as it looks like it might not be directly obtainable, but they have some instructions for how to calculate it. – Joe Feb 02 '15 at 14:23
  • Thanks for the tag suggestion. I saw the link you post it before, but my code is already time consuming (around 2-3 hours since it estimates more than 1000 models and the data set is 'big') so I want to keep it as simple as possible. I cannot beleive SAS does not output the hessian matrix in the logistic procedure! I have done this in matlab and R before. – user1571823 Feb 02 '15 at 14:32
  • Post the question at communities.sas.com and someone from SAS can respond. If there isn't a way, you can also add it as an idea on that site. – Reeza Feb 02 '15 at 14:46
  • You also should consider trying `ods trace on;` before the procedure and checking to see if it is available - I am not familiar with it specifically but a lot of hidden data is available that way. – Joe Feb 02 '15 at 14:51
  • Thanks Joe, I will look into it. However, I missed the point that the covariance matrix of the parater estimates (which is an output in proc logistic) is calculated from the hessian matrix. So can get a good estimate of the hessian by going that way! – user1571823 Feb 02 '15 at 15:14
  • excelent.... my sas version does not contain the INV() function :( – user1571823 Feb 04 '15 at 11:25
  • I came across with this [link](http://www.lexjansen.com/pharmasug/2010/CC/CC15.pdf) It has some usefull macros :) I just hope the macro is not time consuming and my code performance wont be impact. – user1571823 Feb 06 '15 at 07:42
  • Maybe this is useful? http://support.sas.com/documentation/cdl/en/ormpug/67517/HTML/default/viewer.htm#ormpug_nlpsolver_details09.htm – Leo Feb 09 '15 at 04:57

1 Answers1

1

I scoured the SAS blogs and may have found a way you can estimate it using proc nlp.

data t1;
do i = 1 to 500;
x=rannor(3478);
y=1+2*x>rannor(3478);
output;
end;
run;

proc logistic data=t1 outest=parm covout desc;
model y=x/link=probit;
score data=t1 out=t2;
run;

proc nlp data=t1 outest=t2 PHESSIAN;
parms a=0, b=0 ;
max ll;
xbeta = a + b * x;
if y=1 then p=probnorm(xbeta);
else if y=0 then p=1-probnorm(xbeta);
ll=LOG(p);
run;

proc print data=parm(where=(_TYPE_='COV')); run;

*calculation covariance from hessian in above;
proc iml;

HESSIAN={ -143.2141617 64.771275623,
64.771275623 -64.13869603
};
HESSIAN_inv_neg=-inv(HESSIAN);
print HESSIAN ;
print HESSIAN_inv_neg;
quit;

Hope this helps.

Original answer posted here: http://comp.soft-sys.sas.narkive.com/nXdobtA5/hessian-and-scores-in-the-logistic-proc

JJFord3
  • 1,976
  • 1
  • 25
  • 40