[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

From |
"Austin Nichols" <austinnichols@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
st: -ivpois- on SSC, and a call to arms |

Date |
Sun, 11 Nov 2007 11:55:56 -0500 |

Thanks to Kit Baum, the new package -ivpois- is available from SSC; type -ssc install ivpois- to get it. ivpois implements a Generalized Method of Moments (GMM) estimator of Poisson regression and allows endogenous variables to be instrumented by excluded instruments, hence the acronym for Instrumental Variables (IV) in its name. Standard errors are estimated by bootstrapping. Poisson regression assumes E[y|X]=exp(Xb) to get a consistent estimate of b, so it is appropriate for a wide variety of models where the dependent variable is nonnegative (zero or positive), not just where the dependent variable measures counts of events. The central code was promulgated by Bill Gould at a Seminar in DC on November 2, 2007. The code was written at some earlier date and demonstrated at the November 2 seminar by David Drukker, so the package is just a repackaging of others' work, but I thought it was worth advertising what I had not known until that November 2 seminar, namely that a GMM estimator is nearly trivial to write using Mata's optimize command. I had not used Mata at all before the November 2 seminar, but I am now a convert. The guts of the command are just to specify a moment condition: m=((1/rows(Z)):*Z'((y:*exp(-X*b') :- 1)))' and a criterion function to be minimized, which just weights the cross product of that moment condition to get an efficient estimator: crit=(m*W*m') where W=rows(Z)*cholinv(Z'Z). These are wrapped in a Mata function: mata: void iv_pois(todo,b,crit,g,H) { external y,X,Z,W m=((1/rows(Z)):*Z'((y:*exp(-X*b') :- 1)))' crit=(m*W*m') } and then minimizing the criterion function is as simple as specifying the variables in y,X,Z and: init=J(1,cols(X),0) S=optimize_init() optimize_init_evaluator(S, &iv_pois()) optimize_init_which(S,"min") optimize_init_evaluatortype(S,"d0") optimize_init_params(S,init) p=optimize(S) p where the first line defines an initial parameter vector of zeros, the second a name for our optimization problem, and the third the function that will be optimized in that problem. The fourth line specifies whether we seek a min or max, the sixth specifies our initial parameter vector, and the seventh conducts the optimization and assigns the resulting vector to p. The fifth line is the interesting one, and there is some information at type Description "d0" function() returns scalar value "d1" same as "d0" and returns gradient rowvector "d2" same as "d1" and returns Hessian matrix "v0" function() returns colvector value "v1" same as "v0" and returns score matrix "v2" same as "v1" and returns Hessian matrix In short, it is ridiculously easy to program a new GMM estimator in Stata now (Stata 10 is required for the -optimize- command in Mata). If you haven't upgraded to Stata 10 yet, now is the time. I fully expect a host of GMM estimators to flower on SSC in the near future. Presumably, a *generic* GMM estimator is just a matter of specifying a convenient syntax by which users may supply moment conditions on the fly. * * 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/

- Prev by Date:
**Re: st: question about (my) ivreg** - Next by Date:
**st: -rd- on SSC, and a working paper** - Previous by thread:
**st: re: average rate of growth** - Next by thread:
**st: -rd- on SSC, and a working paper** - Index(es):

© Copyright 1996–2014 StataCorp LP | Terms of use | Privacy | Contact us | What's new | Site index |