Good morning everyone,
This is my first post on Statalist so I hope I am doing this right. I am running into some problems with xtdidregress. I saw some other posts on my specific question as well, but I tried to incorporate the feedback on those posts but still run into problems unfortunately. I am trying to carry out a DiD analysis with homogeneous treatment. My dependent variable is patent data running from 1996 - 2021 for a sample of 13 control countries and 20 treated countries. The treatment occurs from 2005 - 2021.This interaction dummy is called 'did' in my dataset and turns 1 for countries part of the treatment group and when the year is >= 2005.
Here is a snippet of the data I am using:
. dataex
This snippet above only includes countries from my treated sample, but the problems should already be highlighted with this sample. After I run xtdidregress:
. xtdidregress (patents) (did), group(Country_ID) time(year)
.
It becomes clear that it does not take into account any observation after 2005. I do not understand why. I have already excluded all countries that had some missing values, even those that only had 1 missing value over the span of 26 years. However, this does not help the problem much. I might have done something very basic wrong, but I do not understand why no data after 2005 is taken into account. STATA does allow me to run estat trendplots, but I do not think it is really appropriate since it's clear something is going wrong in the previous steps. Any help on this topic would be much appreciated!
This is my first post on Statalist so I hope I am doing this right. I am running into some problems with xtdidregress. I saw some other posts on my specific question as well, but I tried to incorporate the feedback on those posts but still run into problems unfortunately. I am trying to carry out a DiD analysis with homogeneous treatment. My dependent variable is patent data running from 1996 - 2021 for a sample of 13 control countries and 20 treated countries. The treatment occurs from 2005 - 2021.This interaction dummy is called 'did' in my dataset and turns 1 for countries part of the treatment group and when the year is >= 2005.
Here is a snippet of the data I am using:
. dataex
Code:
* Example generated by -dataex-. For more info, type help dataex clear input byte Country_ID str20 Country_name int year byte treatment double patents float(time did phase_3) 1 "Austria" 1996 1 161.666666666664 0 0 0 1 "Austria" 1997 1 190.999999999998 0 0 0 1 "Austria" 1998 1 161.616666666665 0 0 0 1 "Austria" 1999 1 190.849999999998 0 0 0 1 "Austria" 2000 1 214.149999999997 0 0 0 1 "Austria" 2001 1 207.249999999996 0 0 0 1 "Austria" 2002 1 184.199999999995 0 0 0 1 "Austria" 2003 1 205.983333333329 0 0 0 1 "Austria" 2004 1 221.883333333327 0 0 0 1 "Austria" 2005 1 232.5 1 1 0 1 "Austria" 2006 1 269.33 1 1 0 1 "Austria" 2007 1 279.03 1 1 0 1 "Austria" 2008 1 309.18 1 1 0 1 "Austria" 2009 1 317.1 1 1 0 1 "Austria" 2010 1 397.06 1 1 0 1 "Austria" 2011 1 405.02 1 1 0 1 "Austria" 2012 1 410.1 1 1 0 1 "Austria" 2013 1 331.73 1 1 1 1 "Austria" 2014 1 366.46 1 1 1 1 "Austria" 2015 1 363.02 1 1 1 1 "Austria" 2016 1 338.28 1 1 1 1 "Austria" 2017 1 369.49 1 1 1 1 "Austria" 2018 1 380.68 1 1 1 1 "Austria" 2019 1 433.24 1 1 1 1 "Austria" 2020 1 404.01 1 1 1 1 "Austria" 2021 1 263.73 1 1 0 2 "Belgium" 1996 1 55.83333333333 0 0 0 2 "Belgium" 1997 1 73.666666666661 0 0 0 2 "Belgium" 1998 1 87.166666666663 0 0 0 2 "Belgium" 1999 1 89.183333333327 0 0 0 2 "Belgium" 2000 1 109.74285714285 0 0 0 2 "Belgium" 2001 1 111.316666666655 0 0 0 2 "Belgium" 2002 1 108.41666666666 0 0 0 2 "Belgium" 2003 1 114.033333333327 0 0 0 2 "Belgium" 2004 1 128.366666666658 0 0 0 2 "Belgium" 2005 1 146.77 1 1 0 2 "Belgium" 2006 1 143.41 1 1 0 2 "Belgium" 2007 1 175.93 1 1 0 2 "Belgium" 2008 1 169.35 1 1 0 2 "Belgium" 2009 1 212.03 1 1 0 2 "Belgium" 2010 1 227.18 1 1 0 2 "Belgium" 2011 1 192.43 1 1 0 2 "Belgium" 2012 1 201.03 1 1 0 2 "Belgium" 2013 1 217.05 1 1 1 2 "Belgium" 2014 1 232.95 1 1 1 2 "Belgium" 2015 1 229.2 1 1 1 2 "Belgium" 2016 1 247.02 1 1 1 2 "Belgium" 2017 1 236.92 1 1 1 2 "Belgium" 2018 1 268.62 1 1 1 2 "Belgium" 2019 1 219.36 1 1 1 2 "Belgium" 2020 1 229.6 1 1 1 2 "Belgium" 2021 1 229.58 1 1 0 3 "Czechia" 1996 1 11.666666666666 0 0 0 3 "Czechia" 1997 1 10.833333333332 0 0 0 3 "Czechia" 1998 1 20.833333333333 0 0 0 3 "Czechia" 1999 1 21.166666666666 0 0 0 3 "Czechia" 2000 1 12.666666666665 0 0 0 3 "Czechia" 2001 1 16.833333333332 0 0 0 3 "Czechia" 2002 1 17.226190476186 0 0 0 3 "Czechia" 2003 1 24.666666666666 0 0 0 3 "Czechia" 2004 1 30.449999999999 0 0 0 3 "Czechia" 2005 1 24.9 1 1 0 3 "Czechia" 2006 1 32.05 1 1 0 3 "Czechia" 2007 1 56.2 1 1 0 3 "Czechia" 2008 1 46.12 1 1 0 3 "Czechia" 2009 1 44.33 1 1 0 3 "Czechia" 2010 1 44.81 1 1 0 3 "Czechia" 2011 1 51.57 1 1 0 3 "Czechia" 2012 1 45.67 1 1 0 3 "Czechia" 2013 1 55.75 1 1 1 3 "Czechia" 2014 1 56.67 1 1 1 3 "Czechia" 2015 1 43.75 1 1 1 3 "Czechia" 2016 1 65.92 1 1 1 3 "Czechia" 2017 1 67.39 1 1 1 3 "Czechia" 2018 1 69.06 1 1 1 3 "Czechia" 2019 1 57.89 1 1 1 3 "Czechia" 2020 1 79.96 1 1 1 3 "Czechia" 2021 1 52.33 1 1 0 4 "Denmark" 1996 1 59.333333333331 0 0 0 4 "Denmark" 1997 1 78.666666666665 0 0 0 4 "Denmark" 1998 1 102.833333333333 0 0 0 4 "Denmark" 1999 1 90.866666666666 0 0 0 4 "Denmark" 2000 1 105.333333333333 0 0 0 4 "Denmark" 2001 1 115.583333333329 0 0 0 4 "Denmark" 2002 1 116.033333333332 0 0 0 4 "Denmark" 2003 1 127.266666666664 0 0 0 4 "Denmark" 2004 1 126.199999999998 0 0 0 4 "Denmark" 2005 1 181.37 1 1 0 4 "Denmark" 2006 1 193.75 1 1 0 4 "Denmark" 2007 1 314.1 1 1 0 4 "Denmark" 2008 1 403.98 1 1 0 4 "Denmark" 2009 1 384.52 1 1 0 4 "Denmark" 2010 1 479.57 1 1 0 4 "Denmark" 2011 1 511.2 1 1 0 4 "Denmark" 2012 1 425.93 1 1 0 4 "Denmark" 2013 1 350.8 1 1 1 4 "Denmark" 2014 1 379.98 1 1 1 4 "Denmark" 2015 1 344.75 1 1 1 4 "Denmark" 2016 1 428.42 1 1 1 4 "Denmark" 2017 1 388.75 1 1 1 end
. xtdidregress (patents) (did), group(Country_ID) time(year)
Code:
Number of groups and treatment time Time variable: year Control: did = 0 Treatment: did = 1 ----------------------------------- | Control Treatment -------------+--------------------- Group | Country_ID | 13 20 -------------+--------------------- Time | Minimum | 1996 2005 Maximum | 1996 2005 ----------------------------------- Difference-in-differences regression Number of obs = 858 Data type: Longitudinal (Std. err. adjusted for 33 clusters in Country_ID) ------------------------------------------------------------------------------ | Robust patents | Coefficient std. err. t P>|t| [95% conf. interval] -------------+---------------------------------------------------------------- ATET | did | (1 vs 0) | -725.1259 487.5723 -1.49 0.147 -1718.278 268.0265 ------------------------------------------------------------------------------ Note: ATET estimate adjusted for panel effects and time effects.
It becomes clear that it does not take into account any observation after 2005. I do not understand why. I have already excluded all countries that had some missing values, even those that only had 1 missing value over the span of 26 years. However, this does not help the problem much. I might have done something very basic wrong, but I do not understand why no data after 2005 is taken into account. STATA does allow me to run estat trendplots, but I do not think it is really appropriate since it's clear something is going wrong in the previous steps. Any help on this topic would be much appreciated!
Comment