Replies: 1 comment 1 reply
-
These commands are not equivalent and should not produce the same results. There is an extensive comparison between the two software packages here: https://marginaleffects.com/vignettes/alternative_software.html |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
My question refers to the R package #marginaleffects and the Stata command margins, which seem to return different estimates for equivalent functions executed in similar ways. The discrepancy is not too large but is not due to rounding rules. I would like to understand why.
Using the mtcars data available in base R,
car <- lm(mpg ~ wt * drat + am, data=mtcars)
library(marginaleffects)
predictions(car, newdata=datagrid(wt=seq(1, 5, by=.5), drat=c(2, 5)))
R retrurns:
Using the same data in Stata, the following command:
reg mpg c.wt##c.drat am margins, at(wt=(1 (.5) 5) drat=(2 5))
-------------+----------------------------------------------------------------
_at |
1 | 20.52733 4.781105 4.29 0.000 10.71731 30.33734
2 | 41.08823 3.768129 10.90 0.000 33.35666 48.81979
3 | 19.90286 4.069634 4.89 0.000 11.55266 28.25306
Thank you!
Beta Was this translation helpful? Give feedback.
All reactions