I'm looking for the code for calculating marginal effects for the logit and count part separately after fitting a hurdle poisson model.
-
Login or Register
- Log in with
help poisson_postestimation
webuse ships, clear hplogit accident co_70_74 co_75_79 op_75_79, nolog *DEFAULT IS XB (LINEAR PREDICTION). NO OFFSET NOR EXPOSURE SPECIFIED. margins, expression(exp(predict(eq(#2)))) dydx(*)
. hplogit accident co_70_74 co_75_79 op_75_79, nolog
Poisson-Logit Hurdle Regression Number of obs = 34
Wald chi2(3) = 0.53
Log likelihood = -252.85156 Prob > chi2 = 0.9113
------------------------------------------------------------------------------
| Coefficient Std. err. z P>|z| [95% conf. interval]
-------------+----------------------------------------------------------------
logit |
co_70_74 | -15.34799 785.9749 -0.02 0.984 -1555.83 1525.135
co_75_79 | -14.96603 1124.472 -0.01 0.989 -2218.89 2188.958
op_75_79 | -.6931546 .9486858 -0.73 0.465 -2.552544 1.166235
_cons | -.0000216 .6324555 -0.00 1.000 -1.239612 1.239568
-------------+----------------------------------------------------------------
poisson |
co_70_74 | -.4402382 .1158772 -3.80 0.000 -.6673534 -.213123
co_75_79 | -1.037688 .1894416 -5.48 0.000 -1.408987 -.6663894
op_75_79 | .1547408 .1127558 1.37 0.170 -.0662566 .3757382
_cons | 2.827939 .0962007 29.40 0.000 2.639389 3.016489
------------------------------------------------------------------------------
AIC Statistic = 15.109
.
. *DEFAULT IS XB (LINEAR PREDICTION). NO OFFSET NOR EXPOSURE SPECIFIED.
.
. margins, expression(exp(predict(eq(#2)))) dydx(*)
Average marginal effects Number of obs = 34
Model VCE: OIM
Expression: exp(predict(eq(#2)))
dy/dx wrt: co_70_74 co_75_79 op_75_79
------------------------------------------------------------------------------
| Delta-method
| dy/dx std. err. z P>|z| [95% conf. interval]
-------------+----------------------------------------------------------------
co_70_74 | -6.470658 1.817137 -3.56 0.000 -10.03218 -2.909135
co_75_79 | -15.25203 2.994656 -5.09 0.000 -21.12144 -9.38261
op_75_79 | 2.274393 1.649322 1.38 0.168 -.9582189 5.507005
------------------------------------------------------------------------------
viewsource jhpoi_logit_ll.ado
webuse ships, clear hplogit accident co_65_69 op_75_79, nolog logit accident co_65_69 op_75_79, nolog
. hplogit accident co_65_69 op_75_79, nolog
Poisson-Logit Hurdle Regression Number of obs = 34
Wald chi2(2) = 1.59
Log likelihood = -269.21136 Prob > chi2 = 0.4507
------------------------------------------------------------------------------
| Coefficient Std. err. z P>|z| [95% conf. interval]
-------------+----------------------------------------------------------------
logit |
co_65_69 | .4266586 .8733348 0.49 0.625 -1.285046 2.138363
op_75_79 | -.9567469 .8379033 -1.14 0.254 -2.599007 .6855134
_cons | -.8417876 .6349363 -1.33 0.185 -2.08624 .4026647
-------------+----------------------------------------------------------------
poisson |
co_65_69 | .4818266 .1097559 4.39 0.000 .2667091 .6969442
op_75_79 | .0018699 .1088363 0.02 0.986 -.2114452 .2151851
_cons | 2.461543 .0960013 25.64 0.000 2.273384 2.649702
------------------------------------------------------------------------------
AIC Statistic = 16.012
.
. logit accident co_65_69 op_75_79, nolog
Logistic regression Number of obs = 34
LR chi2(2) = 1.67
Prob > chi2 = 0.4349
Log likelihood = -17.717553 Pseudo R2 = 0.0449
------------------------------------------------------------------------------
accident | Coefficient Std. err. z P>|z| [95% conf. interval]
-------------+----------------------------------------------------------------
co_65_69 | -.4266584 .8733347 -0.49 0.625 -2.138363 1.285046
op_75_79 | .9567466 .8379032 1.14 0.254 -.6855135 2.599007
_cons | .8417872 .6349362 1.33 0.185 -.4026649 2.086239
------------------------------------------------------------------------------
.
gen newoutcome=!outcome hplogit newoutcome ...
webuse ships clear
hplogit accident co_70_74 co_75_79 op_75_79, nolog
margins, expression(predict(xb)*-1) dydx(*)
. hplogit accident co_70_74 co_75_79 op_75_79, nolog
Poisson-Logit Hurdle Regression Number of obs = 34
Wald chi2(3) = 0.53
Log likelihood = -252.85156 Prob > chi2 = 0.9113
------------------------------------------------------------------------------
| Coefficient Std. err. z P>|z| [95% conf. interval]
-------------+----------------------------------------------------------------
logit |
co_70_74 | -15.34799 785.9749 -0.02 0.984 -1555.83 1525.135
co_75_79 | -14.96603 1124.472 -0.01 0.989 -2218.89 2188.958
op_75_79 | -.6931546 .9486858 -0.73 0.465 -2.552544 1.166235
_cons | -.0000216 .6324555 -0.00 1.000 -1.239612 1.239568
-------------+----------------------------------------------------------------
poisson |
co_70_74 | -.4402382 .1158772 -3.80 0.000 -.6673534 -.213123
co_75_79 | -1.037688 .1894416 -5.48 0.000 -1.408987 -.6663894
op_75_79 | .1547408 .1127558 1.37 0.170 -.0662566 .3757382
_cons | 2.827939 .0962007 29.40 0.000 2.639389 3.016489
------------------------------------------------------------------------------
AIC Statistic = 15.109
.
. margins, expression(predict(xb)*-1) dydx(*)
Average marginal effects Number of obs = 34
Model VCE: OIM
Expression: predict(xb)*-1
dy/dx wrt: co_70_74 co_75_79 op_75_79
------------------------------------------------------------------------------
| Delta-method
| dy/dx std. err. z P>|z| [95% conf. interval]
-------------+----------------------------------------------------------------
co_70_74 | 15.34799 785.9749 0.02 0.984 -1525.135 1555.83
co_75_79 | 14.96603 1124.472 0.01 0.989 -2188.958 2218.89
op_75_79 | .6931546 .9486858 0.73 0.465 -1.166235 2.552545
------------------------------------------------------------------------------
webuse ships, clear hplogit accident co_65_69 op_75_79, nolog poisson accident co_65_69 op_75_79 if accident, nolog
. hplogit accident co_65_69 op_75_79, nolog
Poisson-Logit Hurdle Regression Number of obs = 34
Wald chi2(2) = 1.59
Log likelihood = -269.21136 Prob > chi2 = 0.4507
------------------------------------------------------------------------------
| Coefficient Std. err. z P>|z| [95% conf. interval]
-------------+----------------------------------------------------------------
logit |
co_65_69 | .4266586 .8733348 0.49 0.625 -1.285046 2.138363
op_75_79 | -.9567469 .8379033 -1.14 0.254 -2.599007 .6855134
_cons | -.8417876 .6349363 -1.33 0.185 -2.08624 .4026647
-------------+----------------------------------------------------------------
poisson |
co_65_69 | .4818266 .1097559 4.39 0.000 .2667091 .6969442
op_75_79 | .0018699 .1088363 0.02 0.986 -.2114452 .2151851
_cons | 2.461543 .0960013 25.64 0.000 2.273384 2.649702
------------------------------------------------------------------------------
AIC Statistic = 16.012
.
. poisson accident co_65_69 op_75_79 if accident, nolog
Poisson regression Number of obs = 26
LR chi2(2) = 18.41
Prob > chi2 = 0.0001
Log likelihood = -251.49396 Pseudo R2 = 0.0353
------------------------------------------------------------------------------
accident | Coefficient Std. err. z P>|z| [95% conf. interval]
-------------+----------------------------------------------------------------
co_65_69 | .4818187 .1097539 4.39 0.000 .266705 .6969325
op_75_79 | .0018698 .1088331 0.02 0.986 -.2114391 .2151788
_cons | 2.461551 .0959977 25.64 0.000 2.2734 2.649703
------------------------------------------------------------------------------
webuse ships clear hplogit accident co_70_74 co_75_79 op_75_79, nolog est sto hplogit *LOGIT margins, expression(-predict(eq(#1))) dydx(*) post est sto logit *POISSON est restore hplogit margins, expression(predict(eq(#2))) dydx(*) post est sto poisson *ORIGINAL ESTIMATES esttab hplogit, unstack mlab(none) *TRANSFORMED: LOGIT WITH BASE 0 esttab logit poisson, mlab(logit poisson)
. esttab hplogit, unstack mlab(none)
--------------------------------------------
(1)
logit poisson
--------------------------------------------
co_70_74 -15.35 -0.440***
(-0.02) (-3.80)
co_75_79 -14.97 -1.038***
(-0.01) (-5.48)
op_75_79 -0.693 0.155
(-0.73) (1.37)
_cons -0.0000216 2.828***
(-0.00) (29.40)
--------------------------------------------
N 34
--------------------------------------------
t statistics in parentheses
* p<0.05, ** p<0.01, *** p<0.001
.
. *TRANSFORMED: LOGIT WITH BASE 0
.
. esttab logit poisson, mlab(logit poisson)
--------------------------------------------
(1) (2)
logit poisson
--------------------------------------------
co_70_74 15.35 -0.440***
(0.02) (-3.80)
co_75_79 14.97 -1.038***
(0.01) (-5.48)
op_75_79 0.693 0.155
(0.73) (1.37)
--------------------------------------------
N 34 34
--------------------------------------------
t statistics in parentheses
* p<0.05, ** p<0.01, *** p<0.001
.
Comment