### Friday, December 30, 2005

## Re: st: -ml-based matrices

Stas Kolenikov <skolenik@gmail.com> asks about obtaining the components of the robust VCE when using -ml- to estimate a user-written likelihood or pseudo likelihood.

> I have a likelihood that meets the method -lf- > observation-by-observation form requirements, and I want to get > access to the derivatives matrices, i.e., the components of the > -robust- matrix estimator. Is that possible within -lf- framework, > [...] cumbersome as things always are with -d*- methods? In > ml_max.ado code, I see matrices $ML_CT and $ML_V, but these rather > seems to be the constrained VCE matrix. [...] but again I need the > internal $ML_* names of the matrices to do that [...]

Stas also asks,

> Is this described in the 3rd edition of [ML] at all?

Stas can get access to all of the ML_ results by using the so called interactive mode of -ml-, wherein the -model- and -maximize- statements are issued separately. After maximization, all of the ML_ macros, scalars, and matrices will be left behind. Stas will, however, need to issue a separate -ml display- command to see the results of his estimator because that step is not automated in the interactive mode.

Such interactive use of -ml- is indeed described in all editions of "Maximum Likelihood Estimation with Stat".

My best guess is that this will not provide what Stas is looking for. I suspect that what Stas wants are the two components of the robust/sandwich/linearization VCE -- namely, the observed information matrix (OIM) (also called the inverse hessian) and the outer product of the gradients (OPG). The latter is not left behind in any of the ML_ matrices because it is more efficient to create it on the fly when producing the robust VCE. That is no problem, there are several ways to retrieve the OIM and OPG.

Probably the easiest is to just ask -ml- to compute them for us by telling it that we would like them as our VCE -- both the OIM and OPG are VCEs in their own right. To get the inverse Hessian, Stas can simply specify the option -vce(oim)- on a call to -ml maximize- (or to -ml model- if he is using the maximize option). The VCE for the parameter estimates will be the OIM and he can retrieve it in e(V). Similarly, Stas can retrieve the OPG by specifying the option -vce(opg)-.

If he is concerned about the inefficiency of estimating the model 3 times, Stas can estimate the model once, then initialize the coefficients on each ensuing -ml maximize- statement to the coefficients from the original solution (using the init() option). Adding an -iter(0)- will speed things up even a bit more by preventing the computations required to measure convergence. This will get Stas the components of the robust VCE.

Because the robust VCE is just

-1 V_r = V_i * V_o * V_i * (N / (N-1))

where, V_r is the robust/sandwich/linearization VCE V_i is the OIM VCE V_o is the OPG VCE

Stas can also estimate any two of the VCEs and retrieve the other from those estimates.

-- Vince vwiggins@stata.com

* * For searches and help try: * http://www.stata.com/support/faqs/res/findit.html * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

Tag: statalist