Stata 的 xtnbreg 有 R 函数吗?
一直在使用 Stata 在复制中运行负二项式回归。不确定 Stata 是如何做到这一点的,但想知道是否有 R 函数/包可以做同样的事情? R 会让我更好地了解它是如何工作的,因为我可以看到代码。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
查看
MASS
包中的glm.nb
函数。如果您对“幕后”发生的事情感兴趣,只需在命令提示符下输入函数名称即可查看该函数的源代码。Look into the
glm.nb
function in theMASS
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.如果您更习惯使用 R,那么这可能就是您的选择;但是,如果您对 Stata 中的“幕后”内容感兴趣,您始终可以使用与 R 中相同的方式查看正在运行
的代码(或下载
tr
来自 SSC)或使用查看 xtnbreg 运行的实际代码。
如果您对 Stata 如何计算
xtnbreg
中的结果感兴趣,[XT] 手册第 367-370 页中有关于似然函数的详细讨论,其中包含参考文献。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
to see what code is running (or download
tr
from SSC) or usingto 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.