Code:
regress price c.trunk##c.weight
For example:
Code:
sysuse auto, clear regress price c.trunk##c.weight margins, dydx(trunk) at((p5) weight) at((p50) weight) at((p95) weight) post test _b[1._at] = _b[3._at] test _b[2._at] = _b[3._at]
Code:
. sysuse auto, clear (1978 Automobile Data) . . regress price c.trunk##c.weight Source | SS df MS Number of obs = 74 -------------+------------------------------ F( 3, 70) = 10.01 Model | 190636755 3 63545585.1 Prob > F = 0.0000 Residual | 444428641 70 6348980.58 R-squared = 0.3002 -------------+------------------------------ Adj R-squared = 0.2702 Total | 635065396 73 8699525.97 Root MSE = 2519.7 ---------------------------------------------------------------------------------- price | Coef. Std. Err. t P>|t| [95% Conf. Interval] -----------------+---------------------------------------------------------------- trunk | -287.6778 309.9737 -0.93 0.357 -905.9009 330.5452 weight | 1.172154 1.510518 0.78 0.440 -1.840479 4.184786 | c.trunk#c.weight | .0754153 .0979483 0.77 0.444 -.1199365 .270767 | _cons | 3284.654 4248.161 0.77 0.442 -5188.037 11757.34 ---------------------------------------------------------------------------------- . margins, dydx(trunk) at((p5) weight) at((p50) weight) at((p95) weight) post Average marginal effects Number of obs = 74 Model VCE : OLS Expression : Linear prediction, predict() dy/dx w.r.t. : trunk 1._at : weight = 1830 (p5) 2._at : weight = 3190 (p50) 3._at : weight = 4290 (p95) ------------------------------------------------------------------------------ | Delta-method | dy/dx Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- trunk | _at | 1 | -149.6679 149.0747 -1.00 0.319 -446.9879 147.6521 2 | -47.10315 94.62805 -0.50 0.620 -235.8328 141.6265 3 | 35.85363 155.51 0.23 0.818 -274.3013 346.0086 ------------------------------------------------------------------------------ . . test _b[1._at] = _b[3._at] ( 1) [trunk]1bn._at - [trunk]3._at = 0 F( 1, 70) = 0.59 Prob > F = 0.4439 . test _b[2._at] = _b[3._at] ( 1) [trunk]2._at - [trunk]3._at = 0 F( 1, 70) = 0.59 Prob > F = 0.4439
P.S. I migrated this question from Stack Overflow to Statalist.
0 Response to How to test the difference between marginal effects in Stata
Post a Comment