. #delimit;
delimiter now ;
. sysuse auto, clear;
(1978 Automobile Data)
. gen high_mpg = mpg>22;
. gen high_price = price>6000;
. reg foreign i.high_mpg##i.high_price, robust;
Linear regression Number of obs = 74
F(3, 70) = 8.78
Prob > F = 0.0001
R-squared = 0.2495
Root MSE = .40711
| Robust
foreign | Coef. Std. Err. t P>|t| [95% Conf. Interval]
--------------------+----------------------------------------------------------------
1.high_mpg | .4032258 .1272598 3.17 0.002 .1494142 .6570374
1.high_price | .1385199 .1190367 1.16 0.249 -.0988913 .3759312
|
high_mpg#high_price |
1 1 | .1948134 .2277168 0.86 0.395 -.2593534 .6489802
|
_cons | .0967742 .0545964 1.77 0.081 -.0121149 .2056633
. margins high_mpg#high_price;
Adjusted predictions Number of obs = 74
Model VCE : Robust
Expression : Linear prediction, predict()
| Delta-method
| Margin Std. Err. t P>|t| [95% Conf. Interval]
--------------------+----------------------------------------------------------------
high_mpg#high_price |
0 0 | .0967742 .0545964 1.77 0.081 -.0121149 .2056633
0 1 | .2352941 .1057779 2.22 0.029 .0243267 .4462616
1 0 | .5 .1149534 4.35 0.000 .2707327 .7292673
1 1 | .8333333 .1564318 5.33 0.000 .52134 1.145327
. margins high_price, dydx(high_mpg);
Conditional marginal effects Number of obs = 74
Model VCE : Robust
Expression : Linear prediction, predict()
dy/dx w.r.t. : 1.high_mpg
| Delta-method
| dy/dx Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
0.high_mpg | (base outcome)
-------------+----------------------------------------------------------------
1.high_mpg |
high_price |
0 | .4032258 .1272598 3.17 0.002 .1494142 .6570374
1 | .5980392 .1888382 3.17 0.002 .2214133 .9746652
Note: dy/dx for factor levels is the discrete change from the base level.
. margins r.high_price, dydx(high_mpg);
Contrasts of conditional marginal effects Number of obs = 74
Model VCE : Robust
Expression : Linear prediction, predict()
dy/dx w.r.t. : 1.high_mpg
| df F P>F
-------------+----------------------------------
0b.high_mpg |
high_price | (not testable)
-------------+----------------------------------
1.high_mpg |
high_price | 1 0.73 0.3952
|
Denominator | 70
| Contrast Delta-method
| dy/dx Std. Err. [95% Conf. Interval]
-------------+------------------------------------------------
0.high_mpg | (base outcome)
-------------+------------------------------------------------
1.high_mpg |
high_price |
(1 vs 0) | .1948134 .2277168 -.2593534 .6489802
Note: dy/dx for factor levels is the discrete change from the
base level.
. logit foreign i.high_mpg##i.high_price, nolog;
Logistic regression Number of obs = 74
LR chi2(3) = 18.67
Prob > chi2 = 0.0003
Log likelihood = -35.697459 Pseudo R2 = 0.2073
foreign | Coef. Std. Err. z P>|z| [95% Conf. Interval]
--------------------+----------------------------------------------------------------
1.high_mpg | 2.233592 .7543524 2.96 0.003 .7550886 3.712096
1.high_price | 1.054937 .8342486 1.26 0.206 -.58016 2.690034
|
high_mpg#high_price |
1 1 | .5545007 1.447747 0.38 0.702 -2.283031 3.392032
|
_cons | -2.233592 .6074929 -3.68 0.000 -3.424256 -1.042928
. margins high_mpg#high_price;
Adjusted predictions Number of obs = 74
Model VCE : OIM
Expression : Pr(foreign), predict()
| Delta-method
| Margin Std. Err. z P>|z| [95% Conf. Interval]
--------------------+----------------------------------------------------------------
high_mpg#high_price |
0 0 | .0967742 .0531003 1.82 0.068 -.0073005 .2008489
0 1 | .2352941 .1028794 2.29 0.022 .0336543 .436934
1 0 | .5 .1118034 4.47 0.000 .2808694 .7191306
1 1 | .8333333 .1521452 5.48 0.000 .5351343 1.131532
. margins high_price, dydx(high_mpg);
Conditional marginal effects Number of obs = 74
Model VCE : OIM
Expression : Pr(foreign), predict()
dy/dx w.r.t. : 1.high_mpg
| Delta-method
| dy/dx Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
0.high_mpg | (base outcome)
-------------+----------------------------------------------------------------
1.high_mpg |
high_price |
0 | .4032258 .1237725 3.26 0.001 .1606361 .6458155
1 | .5980392 .1836636 3.26 0.001 .2380652 .9580132
Note: dy/dx for factor levels is the discrete change from the base level.
. margins r.high_price, dydx(high_mpg);
Contrasts of conditional marginal effects Number of obs = 74
Model VCE : OIM
Expression : Pr(foreign), predict()
dy/dx w.r.t. : 1.high_mpg
| df chi2 P>chi2
-------------+----------------------------------
0b.high_mpg |
high_price | (omitted)
-------------+----------------------------------
1.high_mpg |
high_price | 1 0.77 0.3791
| Contrast Delta-method
| dy/dx Std. Err. [95% Conf. Interval]
-------------+------------------------------------------------
0.high_mpg | (base outcome)
-------------+------------------------------------------------
1.high_mpg |
high_price |
(1 vs 0) | .1948134 .2214768 -.2392731 .6288999
Note: dy/dx for factor levels is the discrete change from the
base level.
. logit foreign i.high_mpg if high_price == 0, nolog;
Logistic regression Number of obs = 51
LR chi2(1) = 10.46
Prob > chi2 = 0.0012
Log likelihood = -23.718984 Pseudo R2 = 0.1807
foreign | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
1.high_mpg | 2.233592 .7543524 2.96 0.003 .7550885 3.712096
_cons | -2.233592 .6074929 -3.68 0.000 -3.424256 -1.042928
. margins high_mpg;
Adjusted predictions Number of obs = 51
Model VCE : OIM
Expression : Pr(foreign), predict()
| Delta-method
| Margin Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
high_mpg |
0 | .0967742 .0531003 1.82 0.068 -.0073005 .2008489
1 | .5 .1118034 4.47 0.000 .2808694 .7191306
. margins, dydx(high_mpg);
Conditional marginal effects Number of obs = 51
Model VCE : OIM
Expression : Pr(foreign), predict()
dy/dx w.r.t. : 1.high_mpg
| Delta-method
| dy/dx Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
1.high_mpg | .4032258 .1237725 3.26 0.001 .1606361 .6458155
Note: dy/dx for factor levels is the discrete change from the base level.
. logit foreign i.high_mpg if high_price == 1, nolog;
Logistic regression Number of obs = 23
LR chi2(1) = 6.83
Prob > chi2 = 0.0090
Log likelihood = -11.978475 Pseudo R2 = 0.2219
foreign | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
1.high_mpg | 2.788093 1.235687 2.26 0.024 .3661903 5.209995
_cons | -1.178655 .5717719 -2.06 0.039 -2.299307 -.0580027
. margins high_mpg;
Adjusted predictions Number of obs = 23
Model VCE : OIM
Expression : Pr(foreign), predict()
| Delta-method
| Margin Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
high_mpg |
0 | .2352941 .1028794 2.29 0.022 .0336543 .436934
1 | .8333333 .1521452 5.48 0.000 .5351343 1.131532
. margins, dydx(high_mpg);
Conditional marginal effects Number of obs = 23
Model VCE : OIM
Expression : Pr(foreign), predict()
dy/dx w.r.t. : 1.high_mpg
| Delta-method
| dy/dx Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
1.high_mpg | .5980392 .1836636 3.26 0.001 .2380652 .9580132
Note: dy/dx for factor levels is the discrete change from the base level.