I noticed that I get different results when using MASS::glm.nb as opposed to library(MASS) and then glm.nb. I thought that package::function() would be a good way to avoid namespace conflicts (functions with the same name in different packages used in the same script) and that the results would be equivalent to library(package) and function.
Can anybody explain me why these options lead to different results? Is this a particular issue to do with MASS or can we expect similar behaviour in other packages?
fm_nb_1 <- MASS::glm.nb(mpg ~ cyl+hp, data = mtcars)
library(MASS)
fm_nb_2 <- glm.nb(mpg ~ cyl+hp, data = mtcars)
identical(fm_nb_1,fm_nb_2)
[1] FALSE
Also, the first version cannot be printed with stargazer, while the second version can.
stargazer::stargazer(
fm_nb_1
, type = "text"
)
This gives: % Error: Unrecognized object type.
However, this gives a nice output:
stargazer::stargazer(
fm_nb_2
, type = "text"
)
Output:
==============================================
Dependent variable:
----------------------------
mpg
----------------------------------------------
cyl -0.102**
(0.043)
hp -0.001
(0.001)
Constant 3.790***
(0.146)
----------------------------------------------
Observations 32
Log Likelihood -84.287
theta 894,228.600 (23,863,364.000)
Akaike Inf. Crit. 174.574
==============================================
Note: *p<0.1; **p<0.05; ***p<0.01