Hello,
Does anybody know why margins produce slightly different results depending whether the over option is used (and depending on the order) or not? See example below
Thank you,
Mike
Does anybody know why margins produce slightly different results depending whether the over option is used (and depending on the order) or not? See example below
- first and second syntax produce identical results
- third and fourth syntax differ from each other and from syntax 1 and 2
Code:
. . webuse lbw . reg bwt age lwt i.race i.smoke // Standard OLS regression Source | SS df MS Number of obs = 189 -------------+---------------------------------- F(5, 183) = 6.38 Model | 14831671.2 5 2966334.24 Prob > F = 0.0000 Residual | 85083627.4 183 464937.854 R-squared = 0.1484 -------------+---------------------------------- Adj R-squared = 0.1252 Total | 99915298.6 188 531464.354 Root MSE = 681.86 ------------------------------------------------------------------------------ bwt | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- age | -2.081952 9.816483 -0.21 0.832 -21.44999 17.28609 lwt | 4.000682 1.737547 2.30 0.022 .5724807 7.428883 | race | black | -511.0851 157.0206 -3.25 0.001 -820.8886 -201.2816 other | -400.3064 119.5332 -3.35 0.001 -636.1469 -164.466 | smoke | smoker | -401.1584 109.2028 -3.67 0.000 -616.6168 -185.7 _cons | 2842.58 321.3459 8.85 0.000 2208.561 3476.6 ------------------------------------------------------------------------------ margins i.smoke#i.race Predictive margins Number of obs = 189 Model VCE : OLS Expression : Linear prediction, predict() ---------------------------------------------------------------------------------- | Delta-method | Margin Std. Err. t P>|t| [95% Conf. Interval] -----------------+---------------------------------------------------------------- smoke#race | nonsmoker#white | 3313.569 92.75794 35.72 0.000 3130.556 3496.581 nonsmoker#black | 2802.484 145.2183 19.30 0.000 2515.966 3089.001 nonsmoker#other | 2913.262 86.80869 33.56 0.000 2741.988 3084.537 smoker#white | 2912.41 85.5863 34.03 0.000 2743.547 3081.273 smoker#black | 2401.325 153.4352 15.65 0.000 2098.596 2704.055 smoker#other | 2512.104 125.3539 20.04 0.000 2264.779 2759.429 ---------------------------------------------------------------------------------- . margins i.race#i.smoke Predictive margins Number of obs = 189 Model VCE : OLS Expression : Linear prediction, predict() ---------------------------------------------------------------------------------- | Delta-method | Margin Std. Err. t P>|t| [95% Conf. Interval] -----------------+---------------------------------------------------------------- race#smoke | white#nonsmoker | 3313.569 92.75794 35.72 0.000 3130.556 3496.581 white#smoker | 2912.41 85.5863 34.03 0.000 2743.547 3081.273 black#nonsmoker | 2802.484 145.2183 19.30 0.000 2515.966 3089.001 black#smoker | 2401.325 153.4352 15.65 0.000 2098.596 2704.055 other#nonsmoker | 2913.262 86.80869 33.56 0.000 2741.988 3084.537 other#smoker | 2512.104 125.3539 20.04 0.000 2264.779 2759.429 ---------------------------------------------------------------------------------- . margins i.smoke, over(i.race) Predictive margins Number of obs = 189 Model VCE : OLS Expression : Linear prediction, predict() over : race ---------------------------------------------------------------------------------- | Delta-method | Margin Std. Err. t P>|t| [95% Conf. Interval] -----------------+---------------------------------------------------------------- race#smoke | white#nonsmoker | 3320.305 91.33457 36.35 0.000 3140.1 3500.509 white#smoker | 2919.146 85.72184 34.05 0.000 2750.016 3088.276 black#nonsmoker | 2873.984 140.1653 20.50 0.000 2597.436 3150.532 black#smoker | 2472.826 149.6606 16.52 0.000 2177.543 2768.108 other#nonsmoker | 2875.864 85.56818 33.61 0.000 2707.037 3044.691 other#smoker | 2474.706 122.3741 20.22 0.000 2233.26 2716.151 ---------------------------------------------------------------------------------- . margins i.race, over(i.smoke) Predictive margins Number of obs = 189 Model VCE : OLS Expression : Linear prediction, predict() over : smoke ---------------------------------------------------------------------------------- | Delta-method | Margin Std. Err. t P>|t| [95% Conf. Interval] -----------------+---------------------------------------------------------------- smoke#race | nonsmoker#white | 3317.515 92.33265 35.93 0.000 3135.342 3499.688 nonsmoker#black | 2806.43 144.9946 19.36 0.000 2520.354 3092.506 nonsmoker#other | 2917.208 87.2106 33.45 0.000 2745.141 3089.276 smoker#white | 2906.277 85.74155 33.90 0.000 2737.108 3075.447 smoker#black | 2395.192 153.452 15.61 0.000 2092.43 2697.955 smoker#other | 2505.971 124.5359 20.12 0.000 2260.26 2751.682
Mike
Comment