I think I found a bug with margins. specifically with the atmeans option. If the model is estimated with factor variable notation for a squared term, atmeans uses the square of the mean of the independent variable instead of the mean of the squared variable.
Simple code to replicate issue:
Code:
clear all sysuse auto gen weight2 = c.weight#c.weight summ weight c.weight#c.weight weight2 reg price c.weight##c.weight margins, atmeans reg price weight weight2 margins, atmeans
Code:
Adjusted predictions Number of obs = 74 Model VCE : OLS Expression : Linear prediction, predict() at : weight = 3019.459 (mean) ------------------------------------------------------------------------------ | Delta-method | Margin Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- _cons | 5263.004 374.2033 14.06 0.000 4516.864 6009.144 ------------------------------------------------------------------------------ Adjusted predictions Number of obs = 74 Model VCE : OLS Expression : Linear prediction, predict() at : weight = 3019.459 (mean) weight2 = 9713003 (mean) ------------------------------------------------------------------------------ | Delta-method | Margin Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- _cons | 6165.257 270.6208 22.78 0.000 5625.655 6704.86 ------------------------------------------------------------------------------
Technical details:
Stata/SE 14.2 for Windows (64-bit x86-64)
Revision 13 Jul 2017
0 Response to Bug in margins with factor variable notation for quadratic term
Post a Comment