is there an R function for Stata's xtnbreg?
Asked Answered
E

2

8

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.

Erysipeloid answered 18/8, 2010 at 3:27 Comment(0)
W
4

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.

Wergild answered 18/8, 2010 at 3:45 Comment(0)
I
2

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.

Inmate answered 24/9, 2010 at 23:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.