Is there an R function for Stata xtnbreg?

Used Stata to trigger negative binomial regression in replication. Not sure what is under the hood, how Stata does this, but wanted to know if there is an R function / package that does the same? R will give me a better idea of ​​how this works, as I see the code.

+6
r statistics regression stata
source share
2 answers

Look at the glm.nb function in the MASS package. If you are interested in what happens β€œunder the hood”, you can see the source code of the function by simply entering its name on the command line.

+4
source share

If you prefer using R, then this is probably the way to go; however, if you are interested in what's β€œunder the hood” in Stata, you can always see what happens in much the same way as in R, using

 set trace on 

to find out which code works (or load tr from SSC) or using

 viewsource xtnbreg.ado 

to see the actual code executed by xtnbreg .

If you are interested in how Stata computes results in xtnbreg , a detailed discussion of the likelihood function on the [XT] page on pages 367-370 with links included.

+1
source share

All Articles