views:

69

answers:

2

Have been using STATA to run negative binomial regressions in a replication. Not sure what is under the hood on how STATA does this, but wanted to know if there is an R function/package that does the same thing? The R will give me a better idea of how this works, since I can see the code.

+3  A: 

Look into the glm.nb function in the MASS package. If you're interested in what's happening "under the hood," you can see the source code of the function by just entering its name at the command prompt.

brentonk
here's a link to a glm.nb example: http://www.ats.ucla.edu/stat/r/dae/nbreg.htm
JD Long
A: 

If you're more comfortable using R, then that's probably the way to go; however, if you're interested in what's "under the hood" in Stata, you can always see what's going on in much the same way as in R by using

-set trace on- 

to see what code is running (or download -tr- from SSC) or using

-viewsource xtnbreg.ado- 

to see the actual code that is run by -xtnbreg-.

If you're interested in how Stata is calculating the results in -xtnbreg- there is a detailed discussion of the likelihood function in the [xt] manual page 367-370 with references included.


Eric A. Booth | [email protected] | [email protected]

eric.a.booth