So, I am trying to estimate the effect of contract enforcement on debt maturity (independent var on dep var) using a staggered difference-in-differences specification. The idea is that contract enforcement was introduced in different states on different years. The Dataset includes different codes for different states, different codes for different companies (within a specific state), independent variables and year as a variable for years.
As Follows:
https://ibb.co/JBCV2wM
As previously mentioned, different groups of states have different treatment years. Some states got treated (law passed) starting 1995, others starting 1997, 2000 and 2005. So, essentially we got 4 treatment timelines for different states. As follows: https://ibb.co/M6qgvwD
The task is to calculate the staggered diff-in-diff coefficient for treatment in general!
I started by sorting the dataset using:
sort st_code year
I then created dummy variables for all states and all years so that i can account for state fixed effects and time fixed effects (as far as i am aware):
tabulate st_code , generate(statedummy) tabulate year , generate(yeardummy)
The most important step was to create the treated variable in order to be able to carry out the regression, i did this using the following code: (the conditions correspond to the year of treatment for each state in the dataset)
generate Treated = statedummy1==1 if year >= 1995
replace treated = 1 if ((st_code==3 & year>=1997) | (st_code==4 & year>=1997) | (st_code==5 & year>=1997) | (st_code==6 & year>=1995) | (st_code==8 & year>=1995) | (st_code==9 & year>=1995) | (st_code==10 & year>=1995) | (st_code==11 & year>=2000) | (st_code==12 & year>=1995) | (st_code==13 & year>=1995) | (st_code==14 & year>=1995) | (st_code==17 & year>=1995) | (st_code==18 & year>=1997) | (st_code==19 & year>=1999) | (st_code==20 & year>=2000) | (st_code==22 & year>=1997) | (st_code==26 & year>=1997) | (st_code==27 & year>=1997) | (st_code==29 & year>=1997) | (st_code==30 & year>=1995) | (st_code==31 & year>=1995) | (st_code==33 & year>=1997) | (st_code==36 & year>=1999) | (st_code==37 & year>=1999) | (st_code==38 & year>=1995))
However, when i tried carrying out the regression using this code:
xtreg Longtermdebt_to_totalassets_w treated i.st_code i.year, cluster( st_code )
I kept getting errors. I even tried using different versions or just a reg command but Stata wouldn't let me.
So, I would really appreciate it, if someone would point out what i did wrong or where things went bad.
As Follows:
https://ibb.co/JBCV2wM
As previously mentioned, different groups of states have different treatment years. Some states got treated (law passed) starting 1995, others starting 1997, 2000 and 2005. So, essentially we got 4 treatment timelines for different states. As follows: https://ibb.co/M6qgvwD
The task is to calculate the staggered diff-in-diff coefficient for treatment in general!
I started by sorting the dataset using:
sort st_code year
I then created dummy variables for all states and all years so that i can account for state fixed effects and time fixed effects (as far as i am aware):
tabulate st_code , generate(statedummy) tabulate year , generate(yeardummy)
The most important step was to create the treated variable in order to be able to carry out the regression, i did this using the following code: (the conditions correspond to the year of treatment for each state in the dataset)
generate Treated = statedummy1==1 if year >= 1995
replace treated = 1 if ((st_code==3 & year>=1997) | (st_code==4 & year>=1997) | (st_code==5 & year>=1997) | (st_code==6 & year>=1995) | (st_code==8 & year>=1995) | (st_code==9 & year>=1995) | (st_code==10 & year>=1995) | (st_code==11 & year>=2000) | (st_code==12 & year>=1995) | (st_code==13 & year>=1995) | (st_code==14 & year>=1995) | (st_code==17 & year>=1995) | (st_code==18 & year>=1997) | (st_code==19 & year>=1999) | (st_code==20 & year>=2000) | (st_code==22 & year>=1997) | (st_code==26 & year>=1997) | (st_code==27 & year>=1997) | (st_code==29 & year>=1997) | (st_code==30 & year>=1995) | (st_code==31 & year>=1995) | (st_code==33 & year>=1997) | (st_code==36 & year>=1999) | (st_code==37 & year>=1999) | (st_code==38 & year>=1995))
However, when i tried carrying out the regression using this code:
xtreg Longtermdebt_to_totalassets_w treated i.st_code i.year, cluster( st_code )
I kept getting errors. I even tried using different versions or just a reg command but Stata wouldn't let me.
So, I would really appreciate it, if someone would point out what i did wrong or where things went bad.
Comment