Hi, I was wondering if someone could please help me with a problem I'm having in generating a Difference in Difference regression employing Fixed effects with panel data?
When I include my Treatment group dummy variable and post treatment dummy variable both are omitted by the package due to multicollinearity and I'm not sure why.
My code is below:
ssc install asdoc
ssc install outreg2
cap ado uninstall ftools
net install ftools, from("https://raw.githubusercontent.com/sergiocorreia/ftools/master/src/")
cap ado uninstall reghdfe
net install reghdfe, from("https://raw.githubusercontent.com/sergiocorreia/reghdfe/master/src/")
// Generating Post Treatment Dummy
gen Post=1
replace Post = 0 if year >= 2010 & year <= 2014
tab year Post
// Identifying treatment group and control group
tab val
gen Treatment_Group=1
gen contains_Kansas = strpos(location_name, "Kansas") > 0
replace Treatment_Group = 0 if contains_Kansas == 1
drop contains_Kansas
tab location_name Treatment_Group
// Generating Treatment Effect Coefficient [ ẟ ]
gen Difference_Effect = Treatment_Group * Post
encode location_name, gen(location_name1)
// Graphing the Mortality Rate Trend
bysort year: egen avg_val_NE = mean(val) if Treatment_Group == 1
bysort year: egen avge_val_KS = mean(val) if Treatment_Group == 0
twoway line avg_val_NE avge_val_KS year
// Difference-in-Difference Regression
xtset location_name1 year
xtreg val Treatment_Group Post Difference_Effect, fe // (Here Treatment_Group is omitted but not Post)
// I also tried this where both variables again get omitted
asdoc reghdfe val Treatment_Group Post Difference_Effect, absorb(location_name year)
My data consists of every county in two States in the US across a ten year period, in which the data is organised by county by year
I would be hugely grateful for any help, Thank You!
When I include my Treatment group dummy variable and post treatment dummy variable both are omitted by the package due to multicollinearity and I'm not sure why.
My code is below:
ssc install asdoc
ssc install outreg2
cap ado uninstall ftools
net install ftools, from("https://raw.githubusercontent.com/sergiocorreia/ftools/master/src/")
cap ado uninstall reghdfe
net install reghdfe, from("https://raw.githubusercontent.com/sergiocorreia/reghdfe/master/src/")
// Generating Post Treatment Dummy
gen Post=1
replace Post = 0 if year >= 2010 & year <= 2014
tab year Post
// Identifying treatment group and control group
tab val
gen Treatment_Group=1
gen contains_Kansas = strpos(location_name, "Kansas") > 0
replace Treatment_Group = 0 if contains_Kansas == 1
drop contains_Kansas
tab location_name Treatment_Group
// Generating Treatment Effect Coefficient [ ẟ ]
gen Difference_Effect = Treatment_Group * Post
encode location_name, gen(location_name1)
// Graphing the Mortality Rate Trend
bysort year: egen avg_val_NE = mean(val) if Treatment_Group == 1
bysort year: egen avge_val_KS = mean(val) if Treatment_Group == 0
twoway line avg_val_NE avge_val_KS year
// Difference-in-Difference Regression
xtset location_name1 year
xtreg val Treatment_Group Post Difference_Effect, fe // (Here Treatment_Group is omitted but not Post)
// I also tried this where both variables again get omitted
asdoc reghdfe val Treatment_Group Post Difference_Effect, absorb(location_name year)
My data consists of every county in two States in the US across a ten year period, in which the data is organised by county by year
I would be hugely grateful for any help, Thank You!
Comment