Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    Sunil:
    I overlooked that you imposed cluster-robust standard errors in your regression model, whereas -hausman- allows default standard errors only.
    Hence, you should test -fe- vs -re- specification with the community -contributed command -xtoverid- which, in turns, does not support -fvvarlist- notation, forcing you to prefix your regression model with -xi:- and/or creating interaction by hand.
    I would run -xtoverid- to check whether -fe- is actually the way to go, first.
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #17
      The reason your interaction term is omitted due to colinearity is that your data are incorrectly structured. In the Treat = 0 group, the variable Entry fails to distinguish between the pre- and post- intervention years. In your data, Entry is set to 1 for all years in that group. This is wrong and is the source of the problem you report.

      But, looking a bit more closely at your data, it appears that different fmid's make the transition from Entry = 0 to Entry = 1 in different years. So our data are not suitable for a classical difference in differences analysis. You must go instead to a generalized difference in difference analysis. In this analysis, the variables Entry and Treat play no role. Only the interaction term, EntryTreat will be used. The code will be something like this:
      Code:
      xtreg outcome i.EntryTreat i.year, fe
      The inclusion of i.year is absolutely mandatory here. The generalized DID estimate of your treatment effect will be the coefficient of EntryTreat in the -xtreg- output.

      With that out of the way, let me also reinforce Carlo's observation that the data set you posted was not as helpful as it needed to be: you are asking people to help you troubleshoot a regression, but you post a data set in which nearly all of the variables in the regression are not shown (and the data set is cluttered up with other variables that are not part of the regression and have no apparent relevance to your problem). To make the most out of a forum like this, it is important to show the data that goes along with the code you are asking for help with.

      Comment


      • #18
        Clyde,

        My apologies for not being able to properly format the data. I understand the anxiety created by this. Per your suggestion, I used dataex output and when I cut and paste the data it messed up the format. I have posted below the formatted data for all the variables that I used in my model for you to look at.

        In my model, Entry=1 codes the pre-treatment years and Treat =1 codes for the treated farms. As you have correctly noted for Treat =0 farms, it fails to distinguish between pre-treatment and post-treatment years because they are never treated i.e. there is no post-treatment years for these farms. Also, you have correctly noted that all the treated farms are not treated in the same year, i.e. there is a staggered entry of treatment for the treated farms.

        I want to test if there is any difference in outcome in pre-treatment years for both treated and untreated farms. If I just use the interaction term EntryTreat as you have suggested, it will fail to test the difference in outcome as I intended because EntryTreat =0, would include treated farms in post-treatment years as well as untreated farms in pre-treatment years as shown in the data below. So, if I correctly understood your suggestion, I am not sure just using the interaction term would serve my purpose. Please let me know if I am missing anything here. More clarification is highly appreciated.

        Regards,
        Sunil

        fmid year fmsz dbassra insexp age prcrp prown mcrpyd diff_nincpac Entry Treat EntryTreat
        11402300 1982 2747 62 62.24973 0 1 1 1
        11402300 1983 1784 30 61.79372 0 18.38133 1 1 1
        11402300 1984 1697 28 100 15.08544 24.7158 1 1 1
        11402300 1985 1379 30 100.029 0 -53.2294 1 1 1
        11402300 1986 1243 30 100.0483 0 20.54122 1 1 1
        11402300 1987 1215 35 100 0 24.13819 1 1 1
        11402300 1988 3401 30 52.66098 0 -20.803 1 1 1
        11402300 1989 5156 33 33.87898 0 -23.6661 1 1 1
        11402300 1990 3388 52.47934 0 36.44645 1 1 1
        11402300 1991 2945 38 52.46519 0 -30.1498 1 1 1
        11402300 1995 2888 42 67.86012 0 1 1 1
        11402300 1996 3068 43 69.7425 0 90.96358 1 1 1
        11402300 1997 2963 44 68.66014 0 -42.6524 1 1 1
        11402300 1998 2795 45 66.85509 0 -38.9077 1 1 1
        11402300 1999 2809 46 67.00249 0 14.35262 1 1 1
        11402300 2000 2808 47 66.99786 0 -11.3067 1 1 1
        11402300 2001 2634 48 64.84055 0 7.479562 1 1 1
        11402300 2002 4262 0.84 8169 49 48.43735 0 -23.6915 1 1 1
        11402300 2003 2821 0.98 3775 50 64.11201 0 54.61241 1 1 1
        11402300 2004 2408 0.83 0 51 81.6902 0 -26.3217 1 1 1
        11402300 2005 3188 0.85 17762 52 61.74718 0 4.32806 1 1 1
        11402300 2006 3194.1 0.84 11763.28 53 61.80457 0 -32.2252 1 1 1
        11402300 2007 3207.3 0.92 73028 54 58.37621 0 60.72328 1 1 1
        11402300 2008 3209.4 0.85 4045 54 58.40344 0 -19.0258 1 1 1
        11402300 2009 3185.5 0.81 1843 56 58.09135 0 129.8 58.90582 1 1 1
        11402300 2010 3221.5 0.61 0 57 57.47323 0 96.64959 -59.1106 1 1 1
        11402300 2011 3343.1 0.61 14528 58 57.07576 0 48.34425 29.77052 0 1 0
        11402300 2012 3878.8 0.55 10718 59 56.22358 0 48.47396 -47.0182 0 1 0
        11402300 2013 4549.5 0.591 6754 60 62.61127 0 134.9 74.51344 0 1 0
        11402300 2014 4690.2 0.416 0 61 62.19777 0 100.1331 -42.274 0 1 0
        11402700 1982 2815 55 84.36945 86.92718 106 1 0 0
        11402700 1983 2780 56 84.17266 78.84892 26.13455 1 0 0
        11402700 1984 2633 57 81.57995 0 52 -32.1093 1 0 0
        11402700 1985 2657 58 81.93451 0 90 17.95345 1 0 0
        11402700 1986 2621 59 81.68638 0 90 -36.6751 1 0 0
        11402700 1987 1833 58 73.86252 100 87 55.99545 1 0 0
        11402700 1988 1796 61 73.27394 0 25.52032 1 0 0
        11402700 1989 2274 78.89182 0 76 -32.791 1 0 0
        11402700 1990 2209 60 79.66048 0 30.68497 1 0 0
        11402700 1991 2034 60 75.90954 1.966568 -30.9442 1 0 0
        11402700 1995 2029 40 77.36816 0 55.3 1 0 0
        11402700 1996 2048 41 77.56348 0 130 79.4662 1 0 0
        11402700 1997 1397 42 100 0 108.9 46.65617 1 0 0
        11402700 1998 2304 43 80.90278 0 92 -161.376 1 0 0
        11402700 1999 1860 44 89.24731 0 113 75.3 1 0 0
        11402700 2000 2113 45 78.26313 0 116.6 -112.493 1 0 0
        11402700 2001 1895 46 87.36148 0 104.8 136.3329 1 0 0
        11402700 2003 2608 0.59 0 48 83.15951 0 88.4 1 0 0
        11402700 2004 3263 0.58 65362 49 86.53387 0 154.3 32.16532 1 0 0
        11402700 2005 3390 0.51 23770 50 86.51622 0 61 -64.1125 1 0 0
        11402700 2006 3409 0.67 31122.21 51 86.56497 0 47.4 72.68597 1 0 0
        11402700 2007 3686.2 0.57 238669.3 52 87.57528 4.99159 103.7 45.87577 1 0 0
        11402700 2008 3710 0.51 64217 52 87.65498 0 27.4 106.9243 1 0 0
        11402700 2009 3839 0.31 3200 55 88.53868 0 146.7 -19.26 1 0 0
        11402700 2010 3794 0.38 0 56 88.40274 0 80 -122.834 1 0 0
        11402700 2011 4013 0.38 473868 57 89.03564 0 -39.1038 1 0 0
        11402700 2012 3440 0.31 367042 58 87.2093 0 -3.0989 1 0 0
        11403402 1991 937 37 41.34472 95.30416 1 1 1
        11403402 1992 904 38 97.63274 42.25664 -60.5001 1 1 1
        11403402 1993 1041 39 100.0096 51.8732 -8.44704 1 1 1
        11403402 1994 1883 40 56.22411 54.80616 -17.2001 1 1 1
        11403402 1995 958 41 100.0418 56.88935 -57.4517 1 1 1
        11403402 1996 1505 42 57.78738 79.00332 48.8 55.265 1 1 1
        11403402 1997 1539 43 58.2911 77.64782 63.72388 1 1 1
        11403402 1998 845 44 100.0828 74.08284 -107.588 0 1 0
        11403402 1999 1328 45 64.00603 91.56626 35.1859 0 1 0
        11403402 2000 899 46 98.46497 70.41157 34.28411 0 1 0
        11403402 2001 958 47 100.0104 88.30898 18.9 -52.7391 0 1 0
        11403402 2002 1460 0.6 26744 48 67.30822 93.0137 20.37994 0 1 0
        11403402 2003 1438 0.53 13248 49 66.79416 92.90681 78.4697 0 1 0
        11403402 2004 946 0.52 0 50 100.0846 84.88372 -75.0722 0 1 0
        11403402 2005 1026 0.27 0 51 100.0292 68.22612 -40.2068 0 1 0
        11403402 2006 904.7 0.23 5161 52 100 94.1417 92.10135 0 1 0
        11403402 2007 1252 0.28 88863 53 100.008 80.03993 -27.2374 0 1 0
        11403402 2008 1217.9 0.37 0 53 100 75.96683 61.33228 0 1 0
        11403402 2009 1174.9 0.38 32014 55 100 76.84058 125.3 3.102371 0 1 0
        11403402 2010 1206.4 0.22 0 56 100 77.12202 94.39999 -74.9439 0 1 0
        11403402 2011 1495.3 0.24 172673.3 57 100 53.63472 9.941385 96.91341 0 1 0
        11403402 2012 1138.2 0.23 150527.8 58 100 70.46214 1.95 78.58161 0 1 0
        11403402 2013 1125.8 0.157 0 59 92.54752 71.23823 122.11 -36.9549 0 1 0
        11403402 2014 1089.5 0.187 13721 60 100 79.02708 80.4 -137.194 0 1 0
        11407100 2007 1137.4 0.22 7862 29 100 24.28345 0 1 0
        11407100 2008 1211.5 0.18 0 30 100 22.79819 127.4 188.1835 0 1 0
        11407100 2009 1217.9 0.04 140 31 100 23.09713 -128.894 0 1 0
        11407100 2010 1319.9 0.09 0 32 97.13615 30.93416 89.3 -163.988 0 1 0
        11407100 2011 1318.9 0.19 26155 33 97.05815 30.88179 50.95188 38.85012 0 1 0
        11407100 2012 1321.4 0.14 28899 34 97.06371 30.87634 0 155.5795 0 1 0
        11407100 2013 1398.4 0.108 0 35 97.13959 35.89817 54.56421 0 1 0
        11407100 2014 1121.2 0.211 3353 36 96.4324 44.77346 104.1475 -121.254 0 1 0
        11413000 2013 1860 0.279 3052.35 59 64.22581 54.13979 1 1 1
        11413000 2014 1961.2 0.27 32162 60 60.68733 48.74567 -15.5653 1 1 1
        11482100 1983 4600 35 43.26087 10.86957 1 0 0
        11482100 1984 4770 36 46.85535 10.48218 -19.3558 1 0 0
        11482100 1986 5630 38 33.54885 9.236235 1 0 0
        11482100 1987 4503 42 35.41639 11.10371 12.96028 1 0 0
        11482100 1990 5587 44 42.51297 20.70879 1 0 0
        11482100 1991 6034 45 40.33809 8.170368 -107.419 1 0 0
        11482100 1992 4877 46 46.93459 11.79004 80.45451 1 0 0
        11482100 1993 6384 47 37.73496 9.022556 12.42308 -10.3144 1 0 0
        11482100 1994 3047 48 100 0 91.57233 -7.83307 1 0 0
        11482100 1995 7917 49 40.38525 0 62.46154 -24.117 1 0 0
        11482100 2004 8258 1.52 2928 59 67.52603 0 1 0 0
        11482100 2005 8225 0.82 82161.32 60 67.38724 0 -10.7876 1 0 0
        11482100 2006 9872.2 0.81 16338.44 61 66.6741 0 4.837383 1 0 0
        11482100 2007 9239.7 0.76 154766.6 62 72.78808 6.360596 32.36461 1 0 0
        11482100 2008 9453.4 0.68 102816.4 50 72.0069 0 -20.6736 1 0 0
        11482100 2009 9649.2 0.64 20260.32 60 71.98524 0 51.33526 1 0 0
        11482100 2010 10048.7 0.21 14989 38 70.39418 0 114.0364 -47.0805 1 0 0
        11482100 2011 9829.7 0.3 82612 39 71.78957 0 44.79606 61.60633 1 0 0
        11482100 2012 9901 0.18 217974.1 40 71.99273 0 52.06996 -60.9523 1 0 0
        11482100 2013 10051.5 0.187 6140.82 41 72.41208 0 146.153 40.54168 1 0 0
        11482100 2014 10368.2 0.165 85473 42 73.25476 0 105.1626 -72.482 1 0 0
        11495100 1995 1709 34 78.36747 0 25 1 1 1
        11495100 1996 1880 35 80.31915 0 35 47.73134 1 1 1
        11495100 1997 1870 36 80.24064 0 1.322342 1 1 1
        11495100 1998 1868 37 80.21948 0 -26.5384 1 1 1
        11495100 1999 2094 38 82.33524 6.638013 123 -19.6251 1 1 1
        11495100 2000 2072 39 82.17181 6.708494 114 -9.7599 1 1 1
        11495100 2001 2117 40 82.52244 6.565895 55 -4.34722 1 1 1
        11495100 2002 2159 0.55 23562 41 82.88097 7.132932 -11.2495 1 1 1
        11495100 2003 2067 0.62 2509 42 82.09966 7.353652 41.60542 1 1 1
        11495100 2004 2110 0.4 5392.55 43 82.46445 7.203792 -0.98119 1 1 1
        11495100 2005 1970 0.41 1477 44 89.3401 13.80711 -71.4828 1 1 1
        11495100 2006 1976 0.6 8358.38 45 89.37247 17.30769 29.28703 1 1 1
        11495100 2007 2002 0.62 125241.6 46 89.51049 17.08292 45.54249 1 1 1
        11495100 2008 1982 0.57 0 46 89.40464 17.2553 73.59829 1 1 1
        11495100 2009 1977 0.37 0 48 89.63075 17.29894 -51.4165 1 1 1
        11495100 2010 2202 0.26 0 49 90.69028 15.62216 -26.6656 1 1 1
        11495100 2011 2203 0.38 111437 50 92.73717 15.61507 -17.3922 1 1 1
        11495100 2012 2203.2 0.11 227344 51 92.73784 15.61365 82.50526 1 1 1
        11495100 2013 2227 0.089 0 52 92.81544 15.44679 25.23722 0 1 0
        11495100 2014 2282 0.211 50980 53 92.98861 15.0745 -139.803 0 1 0
        11498100 1998 984 43 51.21951 32.4187 1 1 1
        11498100 1999 1072 44 55.22388 29.75746 97.25472 1 1 1
        11498100 2000 1072 45 55.22388 29.75746 -38.5997 1 1 1
        11498100 2001 995 46 51.75879 30.25126 -34.6561 1 1 1
        11498100 2002 1271 0.43 6620 47 62.23446 25.33438 12.05758 1 1 1
        11498100 2003 1190 0.34 1785 48 51.26051 27.05882 -11.9285 1 1 1
        11498100 2004 1129 0.29 0 49 57.4845 31.17803 107 15.83955 1 1 1
        11498100 2005 1310 0.23 7332 50 55.72519 36.64122 54.02818 1 1 1
        11498100 2006 1456 0.34 17231 51 56.73077 32.96703 60 -63.2122 1 1 1
        11498100 2007 965 0.29 73711 52 83.41969 48.70466 50 64.73859 1 1 1
        11498100 2008 1050 0.26 0 52 84.7619 46.19048 19.38132 1 1 1
        11498100 2009 1588 0.24 11734 54 53.08564 30.54156 120 -112.624 1 1 1
        11498100 2010 1753 0.2 8284 45 52.93782 28.40844 82.5 52.88866 1 1 1
        11498100 2011 1619 0.16 40072.21 46 62.32242 39.53057 15 -11.8537 1 1 1
        11498100 2012 1630 0.33 91254 47 55.21473 41.71779 13.46154 40.49083 1 1 1
        11498100 2013 1567 0.379 10362 48 59.02999 42.75686 0 118.2656 1 1 1
        11498100 2014 1719 0.374 31353 49 57.82432 38.97615 85 -154.649 0 1 0
        11801800 2001 1406 49 85.81792 36.27312 1 1 1
        11801800 2002 1632 0.42 6826 50 85.34927 34.00735 5.504258 1 1 1
        11801800 2003 1228 0.38 11306 51 96.79967 40.39088 12.4222 1 1 1
        11801800 2004 959 0.5 0 52 100.0834 45.1512 -64.7978 1 1 1
        11801800 2005 1292 0.46 0 53 100.0542 36.60991 97.72904 1 1 1
        11801800 2006 1375.7 0.44 0 54 100 35.38562 -78.6359 1 1 1
        11801800 2007 1152.7 0.46 37108 55 100 35.54264 63.38318 1 1 1
        11801800 2008 1466.1 0.43 0 55 100 64.49764 -1.98631 1 1 1
        11801800 2009 1485.1 0.3 0 57 100.0067 47.11467 29.32452 0 1 0
        11801800 2010 1298 0.22 0 58 100 43.29738 18.83815 0 1 0
        11801800 2011 1524.4 0.21 0 59 95.40803 49.85568 38.3519 0 1 0
        11801800 2012 1576.4 0.18 13288 60 96.90434 48.21111 -115.083 0 1 0
        11801800 2013 1574.3 0.213 0 61 97.88477 48.27542 120.1989 0 1 0
        11801800 2014 1775.8 0.186 59518 62 99.79164 42.79761 -154.737 0 1 0
        11802300 1993 274 41 92.70073 100 1 0 0
        11802300 1994 833 42 72.38895 32.77311 102 49.329 1 0 0
        11802300 1995 1439 43 87.14385 19.80542 -6.83802 1 0 0
        11802300 1996 1589 44 90.24544 17.55821 50 36.43363 1 0 0
        11802300 1997 1785 45 89.63586 15.40616 95 12.87458 1 0 0
        11802300 1998 1651 46 88.79467 10.05451 104 -34.7722 1 0 0
        11802300 1999 1787 47 89.64745 9.289311 85 30.59828 1 0 0
        11802300 2000 1760 48 89.5 9.488636 68 -20.793 1 0 0
        11802300 2001 1795 48 89.6936 9.24791 7.300203 1 0 0
        11802300 2002 1921 0.6 9770 49 90.68194 8.328996 -7.43066 1 0 0
        11802300 2003 1921 0.53 7000 50 90.68194 8.328996 65.06544 1 0 0
        11802300 2004 1957 0.46 -1463 51 90.85335 7.256004 -81.6626 1 0 0
        11802300 2005 1710 0.54 0 52 93.45029 7.836257 53 15.17937 1 0 0
        11802300 2006 1263 0.55 2970 54 97.14964 12.5099 45.96368 1 0 0
        11802300 2007 1172.6 0.47 46621.02 55 98.37967 12.02456 2.160885 1 0 0
        11802300 2008 1293.2 0.49 0 55 72.47139 12.23322 95 19.55289 1 0 0
        11802300 2009 1706 0.48 0 57 75.43963 8.264947 22.07103 1 0 0
        11802300 2010 1749 0.44 0 58 76.04346 8.061749 -14.3512 1 0 0
        11802300 2011 1935.9 0.36 44399 59 77.60732 18.07945 6.411263 1 0 0
        11802300 2012 1710.5 0.42 43686 60 78.81905 29.31891 -47.4065 1 0 0
        11802300 2013 1718.6 0.306 0 61 78.81416 29.67532 108 105.3188 1 0 0
        11802300 2014 1759 0.298 0 62 76.63445 28.99375 81 -156.981 1 0 0
        11806000 2006 1223.2 0.1 0 42 53.67887 45.3728 1 1 1
        11806000 2007 1183.7 0.13 8733 43 47.62187 42.57836 76.31805 176.8452 1 1 1
        11806000 2008 1221.6 0.12 2421 43 49.24689 38.97348 98.12933 -414.859 1 1 1
        11806000 2009 1277.5 0.1 0 43 51.46771 41.49511 124.318 140.9868 1 1 1
        11806000 2010 1347.1 0.13 3783 46 53.9752 42.16465 89 234.7461 1 1 1
        11806000 2011 1491.3 0.19 57106 47 56.02494 47.94474 -99.2923 1 1 1
        11806000 2012 1574 0.19 31077 48 57.88437 45.42567 -69.6203 1 1 1
        11806000 2013 1750.5 0.186 0 49 59.28592 40.84547 121 -68.5413 0 1 0
        11806000 2014 1876 0.24 33397 50 61.75373 38.11301 90 64.78239 0 1 0
        11807200 1980 1434 41 93.72385 16.7364 1 0 0
        11807200 1981 1697 42 88.50913 14.1426 29.19524 1 0 0
        11807200 1982 1387 43 94.82336 15.93367 21.26633 1 0 0
        11807200 1983 1366 44 96.01025 16.76427 -58.971 1 0 0
        11807200 1984 1576 45 82.1066 15.22843 19.76654 1 0 0

        Comment


        • #19
          I want to test if there is any difference in outcome in pre-treatment years for both treated and untreated farms. If I just use the interaction term EntryTreat as you have suggested, it will fail to test the difference in outcome as I intended because EntryTreat =0, would include treated farms in post-treatment years as well as untreated farms in pre-treatment years as shown in the data below. So, if I correctly understood your suggestion, I am not sure just using the interaction term would serve my purpose. Please let me know if I am missing anything here. More clarification is highly appreciated.
          Yes, you are missing something. It is a bit complicated to explain, but the use of "just" the EntryTreat interaction will work properly provided you use firmid fixed effects and include i.year in the model as well, as advised in #17. For a full explanation, see https://www.ipr.northwestern.edu/wor.../Day%204.2.pdf. Again, this is not the classical diff-in-diff analysis that you have in mind--but that analysis is simply not possible in a situation where different firms begin treatment at different points in time. This is the generalized diff-in-diff analysis.

          You may, of course, include your other covariates: the code suggested in #17 was just the essential elements of the analysis.

          Per your suggestion, I used dataex output and when I cut and paste the data it messed up the format. I have posted below the formatted data for all the variables that I used in my model for you to look at.
          Thanks for trying, and for the extra effort to make it readable. But I think you do not understand the purpose of -dataex-. The use of -dataex- is not intended to create a display of the data that human eyes will easily read. It is intended to create code that can be copy/pasted into Stata's do-file editor and then run to re-create the data set in Stata. The output of -dataex- is usually not readily understood by human eyes; but that is not the purpose. What is usually needed to provide help is a data set that can be run in Stata, and -dataex- provides the way to create that with assurance that it is faithful in relevant ways to your original data. You might ask why we don't just encourage people to attach their Stata data sets. There are two reasons. One is that we usually don't need to see your whole data: just enough of it to run the analysis you are interested in. The other reason is that some of us will not take the risks inherent in downloading anything from a stranger.

          Comment


          • #20
            Clyde,
            Thanks for your suggestion. I will take a look at the reference you suggested.

            Comment


            • #21
              Clyde,

              The link you provided is not working. Could you please provide the title of the paper and the author name?

              Thanks
              Sunil

              Comment


              • #22
                Hmm! The original link was to a set of slides, not a paper, and I cannot seem to locate it now. Instead of that, have a look at https://www.annualreviews.org/doi/pd...-040617-013507.

                Comment


                • #23
                  Clyde:
                  thanks for the reference.
                  Kind regards,
                  Carlo
                  (Stata 19.0)

                  Comment

                  Working...
                  X