Open jackobailey opened 3 years ago
Here's the R and Stata regression output.
R:
Call:
lm(formula = y ~ x * r, data = dta)
Residuals:
Min 1Q Median 3Q Max
-2.86028 -0.65072 -0.00758 0.69345 2.74165
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.07921 0.04432 1.787 0.0742 .
x 0.24933 0.04513 5.525 4.21e-08 ***
r 0.46209 0.06253 7.390 3.11e-13 ***
x:r 0.70239 0.06355 11.052 < 2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.9879 on 996 degrees of freedom
Multiple R-squared: 0.3453, Adjusted R-squared: 0.3433
F-statistic: 175.1 on 3 and 996 DF, p-value: < 2.2e-16
Stata:
. regress y c.x##i.r
Source | SS df MS Number of obs = 1,000
-------------+---------------------------------- F(3, 996) = 175.09
Model | 512.58423 3 170.86141 Prob > F = 0.0000
Residual | 971.973352 996 .975876859 R-squared = 0.3453
-------------+---------------------------------- Adj R-squared = 0.3433
Total | 1484.55758 999 1.48604363 Root MSE = .98786
------------------------------------------------------------------------------
y | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
x | .2493274 .0451291 5.52 0.000 .1607685 .3378864
1.r | .4620928 .0625298 7.39 0.000 .3393875 .5847981
|
r#c.x |
1 | .7023906 .0635535 11.05 0.000 .5776765 .8271048
|
_cons | .0792121 .0443173 1.79 0.074 -.0077538 .1661781
------------------------------------------------------------------------------
Hello,
Writing to report a possible bug. See below for a reproducible R/Stata toy example.
First, generate a toy data set in R:
Next, fit a simple linear model and get margins using margins.
If we run
vcov(mg1)
we get the covariance matrix for the margins object and it looks something like this:Next, run the same command in Stata:
This gives the following covariance matrix instead:
My question: is this a bug? Or am I doing something stupid?