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.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
Maarten Buis <maartenlbuis@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: gradient and the inverse of the information matrix |

Date |
Thu, 2 May 2013 09:44:59 +0200 |

On Wed, May 1, 2013 at 11:40 PM, Jun Xu wrote: > I am working on a single-equation categorical dependent variable model. I estimated the model with constraints imposed. Then if I understand the score test correctly, it would be a simple matrix operation of > > gradient * inv(information matrix) * gradient' > > where gradient = e(gradient) and inv(information matrix) = e(V) > > But the results do not match those from SAS, at least not to the point of having rounding errors. Either e(gradient) does not mean what it's named or the inverse of information matrix != e(V), I couldn't think of other possibilities. The gradient returned in e(gradient) is what it is supposed to be, but not what you want it to be. What e(gradient) gives you is the gradient of the constrained model at the estimated parameters of the constrained model. What you want is the gradient of the _unconstrained_ model at the parameter values of the constrained model. Many (but not all) Stata commands allow you to get the gradient you are after by first estimating the constrained model, store the parameters, use those parameters at starting values for an unconstrained model using the -from()- option, and specify that you want to get restults after 0 iterations (i.e. just the starting values) using the -iter()- option. Here is an example using -logit-. *------------------ begin example ------------------ // prepare some data sysuse auto, clear sum price gen z_price = ( price - r(mean) ) / r(sd) sum weight gen z_weight = ( weight - r(mean) ) / r(sd) // a logit with a silly constraint constraint 1 z_price = -z_weight logit foreign z_price z_weight, constraint(1) est store c // store the coefficients tempname b0 matrix `b0' = e(b) // repeat that model but get the gradient for the // unconstrained model at the parameter values of // the constrained model logit foreign z_price z_weight, from(`b0') iter(0) // compute the score statistic matrix chi = e(gradient)*e(V)*e(gradient)' matlist chi // compare score statistic with Wald and likelihood ratio // not surprisingly 74 observations is not quite asymptotia logit foreign z_price z_weight lrtest . c test z_price = -z_weight *------------------- end example ------------------- (For more on examples I sent to the Statalist see: http://www.maartenbuis.nl/example_faq ) Hope this helps, Maarten --------------------------------- Maarten L. Buis WZB Reichpietschufer 50 10785 Berlin Germany http://www.maartenbuis.nl --------------------------------- * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/faqs/resources/statalist-faq/ * http://www.ats.ucla.edu/stat/stata/

**Follow-Ups**:**Re: st: gradient and the inverse of the information matrix***From:*Maarten Buis <maartenlbuis@gmail.com>

**References**:**st: gradient and the inverse of the information matrix***From:*Jon Mu <mystata@hotmail.com>

**Re: st: gradient and the inverse of the information matrix***From:*John Antonakis <John.Antonakis@unil.ch>

**RE: st: gradient and the inverse of the information matrix***From:*Jun Xu <mystata@hotmail.com>

- Prev by Date:
**Re: st: automatic joining variables after merging datasets** - Next by Date:
**SV: st: Using values in an variable to save parts of an dataset** - Previous by thread:
**RE: st: gradient and the inverse of the information matrix** - Next by thread:
**Re: st: gradient and the inverse of the information matrix** - Index(es):