I am trying to conduct a difference-in-difference regression model for a binary outcome. So I came across this work Difference-in-differences with an ordinal dependent variable : assessing the impact of the London bombings on the safety perceptions of Muslims (whiterose.ac.uk) that implements Interaction terms in logit and probit models - ScienceDirect non-linear approach. the former implemented the latter to an ordinal outcome model using probit.
Below is the code from the former (I do not have the data):
I understand that I may not use this directly for a binary outcome since a binary outcome is not ordered but I tried to see if I could apply same using logit but there is problem in generating predicted probabilities for subpopulations of the binary outcome.
Below is the code I tried with [0._predict] not found error. Your assistance will be much appreciated. Thanks. Attached is a sample data.
With the following output:
Below is my data:
Below is the code from the former (I do not have the data):
Code:
oprobit Y D T DT x1 x2, vce(robust) margins, dydx(DT) vce(unconditional) subpop(DT) post nlcom [DT]1. predict - [DT]2. predict
Below is the code I tried with [0._predict] not found error. Your assistance will be much appreciated. Thanks. Attached is a sample data.
Code:
logit savemoney kd_did i.age i.period i.progexp [pw=kdweight] if state==2, vce(robust) margin , dydx(kd_did) vce(unconditional) over(kd_did) post nlcom [kd_did]1._predict - [kd_did]2._predict
Code:
. logit savemoney kd_did i.age i.period i.progexp [pw=kdweight] if state==2, vce(robust) Iteration 0: log pseudolikelihood = -701.54708 Iteration 1: log pseudolikelihood = -605.8859 Iteration 2: log pseudolikelihood = -587.40382 Iteration 3: log pseudolikelihood = -586.56099 Iteration 4: log pseudolikelihood = -586.55551 Iteration 5: log pseudolikelihood = -586.55551 Logistic regression Number of obs = 1,168 Wald chi2(8) = 41.97 Prob > chi2 = 0.0000 Log pseudolikelihood = -586.55551 Pseudo R2 = 0.1639 ------------------------------------------------------------------------------------- | Robust savemoney | Coefficient std. err. z P>|z| [95% conf. interval] --------------------+---------------------------------------------------------------- kd_did | 3.167547 .6370738 4.97 0.000 1.918906 4.416189 | age | 16 | .6278054 .947813 0.66 0.508 -1.229874 2.485485 17 | 2.00357 .9929915 2.02 0.044 .0573424 3.949798 18 | .867744 .8106324 1.07 0.284 -.7210664 2.456554 19 | .7230419 .7988291 0.91 0.365 -.8426343 2.288718 20 | 1.230873 .9438616 1.30 0.192 -.6190615 3.080808 | period | Endline | -.4932012 .2819289 -1.75 0.080 -1.045772 .0593693 | progexp | Intervention Group | .1317869 .3128276 0.42 0.674 -.4813439 .7449178 _cons | .4604072 .8164822 0.56 0.573 -1.139869 2.060683 ------------------------------------------------------------------------------------- . margin , dydx(kd_did) vce(unconditional) over(kd_did) post // subpop(kd_did) post Average marginal effects Number of obs = 1,168 Expression: Pr(savemoney), predict() dy/dx wrt: kd_did Over: kd_did ------------------------------------------------------------------------------ | Unconditional | dy/dx std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- kd_did | kd_did | 0 | .6109751 .1309218 4.67 0.000 .3543731 .8675772 1 | .0520365 .0187694 2.77 0.006 .0152492 .0888239 ------------------------------------------------------------------------------ . nlcom [kd_did]0._predict - [kd_did]1._predict [0._predict] not found
Code:
1 1 19 1 1 1.1519125 2 1 1 18 1 1 1.2058938 2 . 0 19 0 1 1 2 1 1 19 1 1 1.1913565 2 1 0 19 0 1 1 2 1 1 19 1 1 .9901584 2 0 0 19 0 1 1 2 . 0 19 0 1 1 2 1 1 20 1 1 1.2315145e-08 2 1 0 19 0 1 1 2 1 1 19 1 1 .747017 2 1 0 19 0 1 1 2 . 0 19 0 1 1 2 1 0 19 0 1 1 2 1 0 19 0 1 1 2 1 0 19 0 1 1 2 1 1 19 1 1 1.002548 2 1 1 19 1 1 .6983826 2 1 0 19 0 1 1 2 1 1 19 1 1 .9901584 2 . 0 19 0 1 1 2 . 0 19 0 1 1 2 1 1 19 1 1 1.1913565 2 1 1 19 1 1 .747017 2 . 0 19 0 1 1 2 . 0 19 0 1 1 2 . 0 17 0 1 1 2 1 1 15 1 1 1.1977272 2 . 0 19 0 1 1 2 1 1 18 1 1 .9097768 2 1 1 19 1 1 .58043873 2 1 0 19 0 1 1 2 1 1 19 1 1 .6983826 2 1 0 18 0 1 1 2 1 1 19 1 1 .9901584 2 1 0 19 0 1 1 2 . 0 19 0 1 1 2 . 0 19 0 1 1 2 1 1 19 1 1 1.1913565 2 1 1 19 1 1 .6983826 2 1 0 19 0 1 1 2 1 1 19 1 1 1.1913565 2 . 0 19 0 1 1 2 . 0 19 0 1 1 2 1 1 19 1 1 .6983826 2 . 0 19 0 1 1 2 1 1 19 1 1 1.1913565 2 . 0 18 0 1 1 2 1 1 19 1 1 .58043873 2 . 0 18 0 1 1 2 1 1 18 1 1 .9097768 2 . 0 17 0 1 1 2 . 0 19 0 1 1 2 . 0 18 0 1 1 2 1 1 19 1 1 .6983826 2 . 0 19 0 1 1 2 . 0 19 0 1 1 2 1 1 19 1 1 1.7102258 2 . 0 18 0 1 1 2 . 0 19 0 1 1 2 1 1 19 1 1 .7460096 2 1 0 19 0 1 1 2 1 1 20 1 1 7.219235e-09 2 . 0 17 0 1 1 2 1 1 17 1 1 .8503983 2 1 1 19 1 1 .9901584 2 . 0 16 0 1 1 2 1 1 19 1 1 .747017 2 . 0 19 0 1 1 2 1 1 19 1 1 1.1913565 2 . 0 19 0 1 1 2 1 1 19 1 1 .58043873 2 . 0 19 0 1 1 2 1 0 16 0 1 1 2 . 0 19 0 1 1 2 1 1 19 1 1 .9901584 2 . 0 19 0 1 1 2 . 0 19 0 1 1 2 1 1 19 1 1 .8950461 2 . 0 17 0 1 1 2 1 1 17 1 1 1.5221377e-07 2 . 0 19 0 1 1 2 1 1 19 1 1 1.1913565 2 1 1 19 1 1 .6983826 2 . 0 19 0 1 1 2 1 1 19 1 1 .6983826 2 . 0 19 0 1 1 2 1 0 19 0 1 1 2 . 0 19 0 1 1 2 1 1 19 1 1 1.1913565 2 1 0 19 0 1 1 2 1 1 19 1 1 1.1913565 2 . 0 19 0 1 1 2 . 0 19 0 1 1 2 1 1 19 1 1 .8988092 2 1 0 19 0 1 1 2 1 1 20 1 1 9.316057e-09 2 1 0 19 0 1 1 2 1 1 20 1 1 6.00004e-09 2 1 0 18 0 1 1 2 end label values savemoney yesno2 label def yesno2 0 "No", modify label def yesno2 1 "Yes", modify label values period period label def period 0 "Baseline", modify label def period 1 "Endline", modify label values progexp exposure label def exposure 1 "Intervention Group", modify label values state state label def state 2 "Kaduna", modify
Comment