Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

is there an R function for Stata's xtnbreg?

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.

like image 494
eric Avatar asked Aug 18 '10 03:08

eric


2 Answers

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.

like image 193
brentonk Avatar answered Nov 18 '22 18:11

brentonk


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.

like image 2
eric.a.booth Avatar answered Nov 18 '22 19:11

eric.a.booth