Dear Statalisters,
I came across an puzzling issue when using xtivreg2. Consider the following example. id and year identify observations uniquely. Note, that treatment and instrument vary by election year not actual year. The outcome varies by year.
I include id and year fixed effects. As the treatment does not vary by year, two units do not contribute to the calculation of the coefficient (num_id==6). Esentially these units are singletons. This goes unreported by xtivreg2, however:
In both cases the command does not indicate that there are singleton observations. Since the coefficient (in my full dataset also the standard error) is exactly the same for both regressions, the number of observations and the number of clusters in the first regression is incorrect: Not all of the observations contribute to the calculation of the coefficient. Note, that consequently also e(sample) does not provide me with the correct estimation sample in the case of the first regression.
Can you replicate this behaviour? Am I missing something?
I came across an puzzling issue when using xtivreg2. Consider the following example. id and year identify observations uniquely. Note, that treatment and instrument vary by election year not actual year. The outcome varies by year.
Code:
* Example generated by -dataex-. For more info, type help dataex clear input int id float(year treatment outcome instrument num_id) 113 1996 .3333333 3.979362 .6666667 6 113 1997 .3333333 3.8868706 .6666667 6 113 1998 .3333333 3.906192 .6666667 6 113 1999 .3333333 3.989638 .6666667 6 113 2000 .3333333 3.9975815 .6666667 6 113 2001 .3333333 4.0859237 .6666667 6 132 2014 .25 5.578712 .3333333 6 132 2015 .25 6.235765 .3333333 6 132 2016 .25 5.772183 .3333333 6 132 2017 .25 5.764741 .3333333 6 132 2018 .25 5.753841 .3333333 6 132 2019 .25 5.766579 .3333333 6 126 2002 .08333333 3.500924 0 12 126 2003 .08333333 3.761655 0 12 126 2004 .08333333 3.858355 0 12 126 2005 .08333333 3.864593 0 12 126 2006 .08333333 4.3667417 0 12 126 2007 .08333333 4.4976387 0 12 126 2008 .16666666 4.772393 1 12 126 2009 .16666666 5.032221 1 12 126 2010 .16666666 4.821508 1 12 126 2011 .16666666 5.042223 1 12 126 2012 .16666666 5.111662 1 12 126 2013 .16666666 5.883927 1 12 119 2002 .3571429 3.940884 0 12 119 2003 .3571429 3.801418 0 12 119 2004 .3571429 3.920975 0 12 119 2005 .3571429 4.344391 0 12 119 2006 .3571429 4.890635 0 12 119 2007 .3571429 5.125267 0 12 119 2014 .3571429 5.838655 0 12 119 2015 .3571429 5.952115 0 12 119 2016 .3571429 6.161406 0 12 119 2017 .3571429 5.836162 0 12 119 2018 .3571429 5.757569 0 12 119 2019 .3571429 5.976904 0 12 127 1996 .57142854 3.834905 .5 12 127 1997 .57142854 3.362425 .5 12 127 1998 .57142854 3.671616 .5 12 127 1999 .57142854 3.715179 .5 12 127 2000 .57142854 3.67317 .5 12 127 2001 .57142854 3.820751 .5 12 127 2008 .14285713 4.922443 0 12 127 2009 .14285713 4.839258 0 12 127 2010 .14285713 4.801708 0 12 127 2011 .14285713 5.172381 0 12 127 2012 .14285713 5.693106 0 12 127 2013 .14285713 5.923906 0 12 209 1996 .25 3.7101324 .5 12 209 1997 .25 3.300654 .5 12 209 1998 .25 3.249974 .5 12 209 1999 .25 3.386469 .5 12 209 2000 .25 3.440905 .5 12 209 2001 .25 3.852433 .5 12 209 2008 .4375 5.13156 1 12 209 2009 .4375 5.058382 1 12 209 2010 .4375 4.995381 1 12 209 2011 .4375 5.203205 1 12 209 2012 .4375 5.268362 1 12 209 2013 .4375 5.311003 1 12 end
I include id and year fixed effects. As the treatment does not vary by year, two units do not contribute to the calculation of the coefficient (num_id==6). Esentially these units are singletons. This goes unreported by xtivreg2, however:
Code:
xtset id year xi: xtivreg2 outcome (treatment = instrument) i.year, r cluster(id) fe partial(i.year) xi: xtivreg2 outcome (treatment = instrument) i.year if num_id!=6, r cluster(id) fe partial(i.year)
Can you replicate this behaviour? Am I missing something?
Comment