Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.

# Re: st: How to save a hessian matrix for post-estimation analysis?

 From Gordon Hughes To statalist@hsphsun2.harvard.edu Subject Re: st: How to save a hessian matrix for post-estimation analysis? Date Mon, 20 Aug 2012 10:13:00 +0100

There is no general answer to this question. Further, it is unclear whether you are interested in recovering the Hessian for a standard Stata ML command or for an ML procedure that you have written yourself.
```
```
For standard Stata procedures, the Hessian option in -maximize- controls printed log output rather than what matrices are saved. If you really need the Hessian, you will almost certainly have to modify the Stata procedure - producing your own variant -my_xxx- to persuade either -ml- or -optimize/moptimize- (in Mata) to return and save the Hessian in a specified Stata matrix. Of course, this may be quite a lot of effort to avoid degenerate examples of e(V), most of which can be handled by some simple Mata commands calling either qrinv() or pinv() to construct a generalised inverse.
```
```
If you are writing your own ML procedure, then the most direct way of getting to the Hessian is to use -optimize- in a Mata procedure which provides optimize_result_Hessian as a way of recovering the Hessian.
```
Regards

Gordon Hughes
g.a.hughes@ed.ac.uk

====================================

Dear Statalist,

```
I'm looking for a way to save a hessian matrix. Specifically, when fitting a likelihood-based model, I know that specifying the option "hessian" can show the hessian matrix, but how can I store it for post-estimation analysis?
```
```
I don't wanna got the hessian matrix via "-1*invsym(e(V))", because under certain circumstances, that can't recover the original hessian matrix. (For example, when the hessian matrix is not negative definite, some columns and rows of the e(V) will be set to be zero. Then, "-1*invsym(e(V))" cannot recover the original hessian matrix.)
```
Thanks for the help in advance.

Best Regards,

Chi-lin Tsai

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```