I am trying to understand the Jeff Wooldridge DiD estimation with more and binary covariates:
Here is a try at extending the example to three covariates
However, the results are way off from what we got with only 1 covariate so I am thinking maybe it is too much?

- Do we also center binary X? Isn't a bit strange to have the effect then for a value that the X cannot take?
- How many orders of interactions do we have to do as the number of covariates grows? For example, do we also have to take x1#x2#x3#d or just each covariate separately with x? And do we have to also interact all the covariates x1#x2#x3?
Code:
* Example generated by -dataex-. For more info, type help dataex clear input int(id year) byte(f01 f02 f03 f04 f05 f06) float(x0 x1 c u) byte d float(y0 y1 y) byte w float(te x2 x3) 1 2004 0 0 0 1 0 0 .3060876 .8999839 -1.3061992 -3.04351 0 16.500282 17.932508 16.500282 0 1.4322262 1 20.25588 1 2005 0 0 0 0 1 0 1.6481395 .8999839 -1.3061992 .3134679 0 19.95726 23.33045 19.95726 0 3.37319 1 20.25588 1 2003 0 0 1 0 0 0 .06370142 .8999839 -1.3061992 -.8482413 0 18.295551 18.295551 18.295551 0 0 1 20.25588 1 2006 0 0 0 0 0 1 1.6340377 .8999839 -1.3061992 .12209804 0 19.86589 26.33341 19.86589 0 6.46752 1 20.25588 1 2002 0 1 0 0 0 0 .58702457 .8999839 -1.3061992 -1.2422227 0 17.90157 17.90157 17.90157 0 0 1 20.25588 1 2001 1 0 0 0 0 0 1.1609128 .8999839 -1.3061992 -.7842262 0 18.359566 18.359566 18.359566 0 0 1 20.25588 2 2003 0 0 1 0 0 0 .19957064 .6742038 -.7233599 -1.6929256 0 17.920816 17.920816 17.920816 0 0 0 13.326492 2 2004 0 0 0 1 0 0 .7170104 .6742038 -.7233599 -1.2869654 0 18.726776 21.47781 18.726776 0 2.751036 0 13.326492 2 2001 1 0 0 0 0 0 .05028351 .6742038 -.7233599 -1.328019 0 18.285723 18.285723 18.285723 0 0 0 13.326492 2 2002 0 1 0 0 0 0 1.2363397 .6742038 -.7233599 -.6061192 0 19.007624 19.007624 19.007624 0 0 0 13.326492 2 2005 0 0 0 0 1 0 1.3075325 .6742038 -.7233599 .05444764 0 20.16819 27.04854 20.16819 0 6.880352 0 13.326492 2 2006 0 0 0 0 0 1 .5344856 .6742038 -.7233599 3.03409 0 23.24783 26.72519 23.24783 0 3.477356 0 13.326492 3 2006 0 0 0 0 0 1 .52091265 .7763655 .6008372 .4699862 0 22.059006 28.1483 22.059006 0 6.089294 1 7.5213 3 2003 0 0 1 0 0 0 .4469955 .7763655 .6008372 1.8585327 0 22.847553 22.847553 22.847553 0 0 1 7.5213 3 2005 0 0 0 0 1 0 .16134594 .7763655 .6008372 5.007066 0 26.496086 32.284145 26.496086 0 5.788059 1 7.5213 3 2001 1 0 0 0 0 0 2.92056 .7763655 .6008372 .9024155 0 21.891436 21.891436 21.891436 0 0 1 7.5213 3 2002 0 1 0 0 0 0 .58282447 .7763655 .6008372 -.11955032 0 20.86947 20.86947 20.86947 0 0 1 7.5213 3 2004 0 0 0 1 0 0 .025554806 .7763655 .6008372 -2.1035151 0 19.285505 21.11419 19.285505 0 1.828684 1 7.5213 4 2001 1 0 0 0 0 0 1.1238233 1.449669 .4445452 -2.695343 0 18.474037 18.474037 18.474037 0 0 0 24.36316 4 2006 0 0 0 0 0 1 3.1662574 1.449669 .4445452 1.4399977 0 23.20938 31.30966 23.20938 0 8.100281 0 24.36316 4 2002 0 1 0 0 0 0 .17738506 1.449669 .4445452 -2.460038 0 18.709341 18.709341 18.709341 0 0 0 24.36316 4 2003 0 0 1 0 0 0 2.2930093 1.449669 .4445452 .10792396 0 21.277304 21.277304 21.277304 0 0 0 24.36316 4 2005 0 0 0 0 1 0 1.7174016 1.449669 .4445452 .27073693 0 21.940117 26.899115 21.940117 0 4.958998 0 24.36316 4 2004 0 0 0 1 0 0 .2201381 1.449669 .4445452 1.0744053 0 22.643785 27.047035 22.643785 0 4.4032497 0 24.36316 5 2006 0 0 0 0 0 1 .06161892 1.481589 .0309765 1.0129526 0 22.384724 24.389465 22.384724 0 2.0047417 1 17.433357 5 2001 1 0 0 0 0 0 .55583376 1.481589 .0309765 .01085913 0 20.78263 20.78263 20.78263 0 0 1 17.433357 5 2004 0 0 0 1 0 0 1.2494304 1.481589 .0309765 3.886539 0 25.05831 30.0035 25.05831 0 4.94519 1 17.433357 5 2002 0 1 0 0 0 0 .12433722 1.481589 .0309765 .3325454 0 21.104317 21.104317 21.104317 0 0 1 17.433357 5 2003 0 0 1 0 0 0 .33023635 1.481589 .0309765 3.059907 0 23.83168 23.83168 23.83168 0 0 1 17.433357 5 2005 0 0 0 0 1 0 6.568078 1.481589 .0309765 1.451638 0 22.72341 25.80217 22.72341 0 3.078762 1 17.433357 6 2002 0 1 0 0 0 0 .15857266 .4216814 -1.5163058 1.9113857 0 20.60592 20.60592 20.60592 0 0 0 6.055562 6 2003 0 0 1 0 0 0 .4737925 .4216814 -1.5163058 .372273 0 19.066809 19.066809 19.066809 0 0 0 6.055562 6 2001 1 0 0 0 0 0 .6631577 .4216814 -1.5163058 -2.0006878 0 16.693848 16.693848 16.693848 0 0 0 6.055562 6 2005 0 0 0 0 1 0 .8055798 .4216814 -1.5163058 3.693907 0 22.88844 29.61216 22.88844 0 6.723721 0 6.055562 6 2004 0 0 0 1 0 0 .09303146 .4216814 -1.5163058 -2.445572 0 16.648962 19.23068 16.648962 0 2.58172 0 6.055562 6 2006 0 0 0 0 0 1 .33595455 .4216814 -1.5163058 -1.6402093 0 17.654325 24.942156 17.654325 0 7.28783 0 6.055562 7 2003 0 0 1 0 0 0 2.819954 2.2678227 .7179165 4.1437035 1 23.99553 23.99553 23.99553 0 0 1 10.237764 7 2001 1 0 0 0 0 0 .37007815 2.2678227 .7179165 .3543251 1 20.206154 20.206154 20.206154 0 0 1 10.237764 7 2005 0 0 0 0 1 0 1.451097 2.2678227 .7179165 -.18847714 1 20.16335 24.9257 24.9257 1 4.7623463 1 10.237764 7 2002 0 1 0 0 0 0 3.602984 2.2678227 .7179165 -3.009033 1 16.842794 16.842794 16.842794 0 0 1 10.237764 7 2004 0 0 0 1 0 0 .9396546 2.2678227 .7179165 2.77177 1 23.0236 28.11396 28.11396 1 5.090361 1 10.237764 7 2006 0 0 0 0 0 1 4.423169 2.2678227 .7179165 4.6137824 1 25.06561 30.886784 30.886784 1 5.821173 1 10.237764 8 2006 0 0 0 0 0 1 2.153845 1.35818 1.555748 -.08226311 0 22.752575 28.737257 22.752575 0 5.984682 0 3.103299 8 2005 0 0 0 0 1 0 .4518185 1.35818 1.555748 -.7949974 0 21.93984 27.426264 21.93984 0 5.486423 0 3.103299 8 2004 0 0 0 1 0 0 1.9123118 1.35818 1.555748 .9501973 0 23.585035 23.50792 23.585035 0 -.07711792 0 3.103299 8 2002 0 1 0 0 0 0 1.718524 1.35818 1.555748 -3.419948 0 18.81489 18.81489 18.81489 0 0 0 3.103299 8 2001 1 0 0 0 0 0 .6112706 1.35818 1.555748 -.18530323 0 22.049534 22.049534 22.049534 0 0 0 3.103299 8 2003 0 0 1 0 0 0 1.3013097 1.35818 1.555748 -1.2717605 0 20.96308 20.96308 20.96308 0 0 0 3.103299 9 2004 0 0 0 1 0 0 .24888325 1.2267038 -1.8302025 -2.40967 1 14.77348 18.539341 18.539341 1 3.7658615 1 7.103189 9 2001 1 0 0 0 0 0 .8760293 1.2267038 -1.8302025 3.524959 1 20.30811 20.30811 20.30811 0 0 1 7.103189 9 2003 0 0 1 0 0 0 .9204704 1.2267038 -1.8302025 .8833148 1 17.666464 17.666464 17.666464 0 0 1 7.103189 9 2006 0 0 0 0 0 1 5.113919 1.2267038 -1.8302025 3.549654 1 20.932804 26.25754 26.25754 1 5.324738 1 7.103189 9 2002 0 1 0 0 0 0 .13916393 1.2267038 -1.8302025 -.9547358 1 15.828414 15.828414 15.828414 0 0 1 7.103189 9 2005 0 0 0 0 1 0 .06175615 1.2267038 -1.8302025 1.7848247 1 19.067974 25.55248 25.55248 1 6.484509 1 7.103189 10 2002 0 1 0 0 0 0 .43844765 .4105914 -1.5521548 -2.1601157 1 14.493025 14.493025 14.493025 0 0 0 17.930876 10 2005 0 0 0 0 1 0 .8831286 .4105914 -1.5521548 -.7734712 1 16.37967 19.114056 19.114056 1 2.7343864 0 17.930876 10 2004 0 0 0 1 0 0 .413378 .4105914 -1.5521548 .5969602 1 17.6501 20.411837 20.411837 1 2.761736 0 17.930876 10 2006 0 0 0 0 0 1 .14171585 .4105914 -1.5521548 2.750983 1 20.004124 25.92111 25.92111 1 5.916985 0 17.930876 10 2003 0 0 1 0 0 0 .06419521 .4105914 -1.5521548 .4602623 1 17.113403 17.113403 17.113403 0 0 0 17.930876 10 2001 1 0 0 0 0 0 .5226828 .4105914 -1.5521548 -.05229951 1 16.600842 16.600842 16.600842 0 0 0 17.930876 11 2001 1 0 0 0 0 0 .6422579 .9265445 -4.3990397 -.4590163 1 13.605216 13.605216 13.605216 0 0 1 10.327092 11 2003 0 0 1 0 0 0 .5846129 .9265445 -4.3990397 2.3547597 1 16.418993 16.418993 16.418993 0 0 1 10.327092 11 2004 0 0 0 1 0 0 2.1288738 .9265445 -4.3990397 -1.239237 1 13.224996 13.350397 13.350397 1 .1254015 1 10.327092 11 2006 0 0 0 0 0 1 1.0985651 .9265445 -4.3990397 1.735612 1 16.399845 23.97114 23.97114 1 7.571297 1 10.327092 11 2002 0 1 0 0 0 0 .17319475 .9265445 -4.3990397 -.17446163 1 13.88977 13.88977 13.88977 0 0 1 10.327092 11 2005 0 0 0 0 1 0 .9317628 .9265445 -4.3990397 -1.6626803 1 12.901552 18.886393 18.886393 1 5.98484 1 10.327092 12 2005 0 0 0 0 1 0 .7289661 .8532412 -1.7565117 1.2556676 0 20.42578 24.444366 20.42578 0 4.018589 0 7.90556 12 2006 0 0 0 0 0 1 .6080928 .8532412 -1.7565117 -2.910625 0 16.359484 23.278046 16.359484 0 6.918562 0 7.90556 12 2001 1 0 0 0 0 0 2.067974 .8532412 -1.7565117 1.5269603 0 20.19707 20.19707 20.19707 0 0 0 7.90556 12 2004 0 0 0 1 0 0 .6054283 .8532412 -1.7565117 -1.9526075 0 17.117502 19.585154 17.117502 0 2.4676514 0 7.90556 12 2002 0 1 0 0 0 0 .04738205 .8532412 -1.7565117 -2.8624616 0 15.807648 15.807648 15.807648 0 0 0 7.90556 12 2003 0 0 1 0 0 0 1.0616038 .8532412 -1.7565117 -2.705209 0 15.9649 15.9649 15.9649 0 0 0 7.90556 13 2003 0 0 1 0 0 0 .22429258 1.0197799 -5.042834 -.49931705 0 14.96774 14.96774 14.96774 0 0 1 12.138537 13 2006 0 0 0 0 0 1 1.1751271 1.0197799 -5.042834 -2.968002 0 13.099053 19.35392 13.099053 0 6.254867 1 12.138537 13 2005 0 0 0 0 1 0 .7750041 1.0197799 -5.042834 .9949038 0 16.96196 18.287554 16.96196 0 1.325594 1 12.138537 13 2004 0 0 0 1 0 0 .4676123 1.0197799 -5.042834 2.1828074 0 18.049864 19.508 18.049864 0 1.4581356 1 12.138537 13 2002 0 1 0 0 0 0 2.0277784 1.0197799 -5.042834 -1.0009137 0 14.466142 14.466142 14.466142 0 0 1 12.138537 13 2001 1 0 0 0 0 0 1.4488647 1.0197799 -5.042834 -.16259946 0 15.304456 15.304456 15.304456 0 0 1 12.138537 14 2005 0 0 0 0 1 0 .28565294 .8468386 .17828622 2.0193295 1 21.121035 27.22845 27.22845 1 6.107416 0 4.854001 14 2004 0 0 0 1 0 0 .9807044 .8468386 .17828622 -1.837703 1 17.164003 23.513033 23.513033 1 6.34903 0 4.854001 14 2003 0 0 1 0 0 0 1.1919093 .8468386 .17828622 -.017519366 1 18.584187 18.584187 18.584187 0 0 0 4.854001 14 2002 0 1 0 0 0 0 .9409264 .8468386 .17828622 .023804275 1 18.62551 18.62551 18.62551 0 0 0 4.854001 14 2006 0 0 0 0 0 1 .4886237 .8468386 .17828622 -1.0913773 1 18.110329 22.842997 22.842997 1 4.732668 0 4.854001 14 2001 1 0 0 0 0 0 1.1932147 .8468386 .17828622 -1.229629 1 17.372076 17.372076 17.372076 0 0 0 4.854001 15 2003 0 0 1 0 0 0 .7850884 1.2177105 2.8261676 -2.441496 0 20.993526 20.993526 20.993526 0 0 1 17.053638 15 2002 0 1 0 0 0 0 .22712035 1.2177105 2.8261676 -.23791227 0 23.19711 23.19711 23.19711 0 0 1 17.053638 15 2005 0 0 0 0 1 0 2.1530826 1.2177105 2.8261676 .24793527 0 24.18296 27.45808 24.18296 0 3.275122 1 17.053638 15 2001 1 0 0 0 0 0 .42704725 1.2177105 2.8261676 1.3548107 0 24.789833 24.789833 24.789833 0 0 1 17.053638 15 2006 0 0 0 0 0 1 1.1538873 1.2177105 2.8261676 -2.4069495 0 21.62807 26.95773 21.62807 0 5.329655 1 17.053638 15 2004 0 0 0 1 0 0 2.5600374 1.2177105 2.8261676 -1.515538 0 22.319485 26.113136 22.319485 0 3.7936516 1 17.053638 16 2002 0 1 0 0 0 0 1.649291 .8262194 -3.039424 -.4664764 1 14.90721 14.90721 14.90721 0 0 0 3.632325 16 2006 0 0 0 0 0 1 .9343096 .8262194 -3.039424 -1.0802279 1 14.893457 20.608376 20.608376 1 5.714918 0 3.632325 16 2001 1 0 0 0 0 0 .4561211 .8262194 -3.039424 -1.511918 1 13.861768 13.861768 13.861768 0 0 0 3.632325 16 2003 0 0 1 0 0 0 1.208848 .8262194 -3.039424 -2.5091746 1 12.86451 12.86451 12.86451 0 0 0 3.632325 16 2005 0 0 0 0 1 0 .12327927 .8262194 -3.039424 1.5102085 1 17.383894 24.67079 24.67079 1 7.286896 0 3.632325 16 2004 0 0 0 1 0 0 .5854673 .8262194 -3.039424 .3695994 1 16.143286 19.57702 19.57702 1 3.433737 0 3.632325 17 2002 0 1 0 0 0 0 1.905228 .54959255 1.8770715 -1.1472305 0 21.004637 21.004637 21.004637 0 0 1 20.80849 17 2006 0 0 0 0 0 1 .3304343 .54959255 1.8770715 -1.8845243 0 20.867344 25.007227 20.867344 0 4.139883 1 20.80849 17 2003 0 0 1 0 0 0 .2024587 .54959255 1.8770715 -1.2083232 0 20.943544 20.943544 20.943544 0 0 1 20.80849 17 2001 1 0 0 0 0 0 .22234537 .54959255 1.8770715 1.6832645 0 23.83513 23.83513 23.83513 0 0 1 20.80849 end
Here is a try at extending the example to three covariates
Code:
sum x1 if d gen x1_dm = x1 - r(mean) sum x2 if d gen x2_dm = x2 - r(mean) sum x3 if d gen x3_dm = x3 - r(mean) reg y c.d#c.f04 c.d#c.f05 c.d#c.f06 c.year d x1_dm x2_dm x3_dm /// c.d#c.f04#c.x1_dm c.d#c.f05#c.x1_dm c.d#c.f06#c.x1_dm c.year#c.x1_dm c.d#c.x1_dm /// c.d#c.f04#c.x2_dm c.d#c.f05#c.x2_dm c.d#c.f06#c.x2_dm c.year#c.x2_dm c.d#c.x2_dm /// c.d#c.f04#c.x3_dm c.d#c.f05#c.x3_dm c.d#c.f06#c.x3_dm c.year#c.x3_dm c.d#c.x3_dm /// c.d#c.f04#c.x1_dm#c.x2_dm c.d#c.f05#c.x1_dm#c.x2_dm c.d#c.f06#c.x1_dm#c.x2_dm c.year#c.x1_dm#c.x2_dm c.d#c.x1_dm#c.x2_dm /// c.d#c.f04#c.x1_dm#c.x3_dm c.d#c.f05#c.x1_dm#c.x3_dm c.d#c.f06#c.x1_dm#c.x3_dm c.year#c.x1_dm#c.x3_dm c.d#c.x1_dm#c.x3_dm /// c.d#c.f04#c.x2_dm#c.x3_dm c.d#c.f05#c.x2_dm#c.x3_dm c.d#c.f06#c.x2_dm#c.x3_dm c.year#c.x2_dm#c.x3_dm c.d#c.x2_dm#c.x3_dm /// c.d#c.f04#c.x1_dm#c.x2_dm#c.x3_dm c.d#c.f05#c.x1_dm#c.x2_dm#c.x3_dm c.d#c.f06#c.x1_dm#c.x2_dm#c.x3_dm /// c.year#c.x1_dm#c.x2_dm#c.x3_dm c.d#c.x1_dm#c.x2_dm#c.x3_dm /// c.x1_dm#c.x2_dm c.x2_dm#c.x3_dm c.x1_dm#c.x3_dm c.x1_dm#c.x2_dm#c.x3_dm /// , vce(cluster id)
However, the results are way off from what we got with only 1 covariate so I am thinking maybe it is too much?
Comment