I am currently trying to create the usual Diff in Diff Graph e.g:
Array
My setting:
- I have panel data of about 4 million German companies.
- I regress the yearly log total assets growth of those companies on a business tax levy increase dummy of the municipal the respective firm is located in. The dummy is one if the municipal increased the business tax levy this year
- I am expecting that there is a negative effect on log total assets growth of a firm within the same year and the years after the municipal increased the tax.
- I have 16 years, 11.000 municipals and 1500 tax increase events. So I have to standardize the x-axis to event time instead of years.
Array
Using the following Code:
Code:
//Firm  and state  control variables
    xtset bvd_id year
    local independent "F3.hebesatzIncreaseDummy F2.hebesatzIncreaseDummy F1.hebesatzIncreaseDummy hebesatzIncreaseDummy L1.hebesatzIncreaseDummy L2.hebesatzIncreaseDummy L3.hebesatzIncreaseDummy"
    local firmControls "L1.assets_total_million L1.ratio_leverage L1.ratio_leverage_change age" // assets_total_log age
    local stateControls "L1.gspGrowthRate L1.gspGrowthRate_change L1.unemploymentRate L1.unemploymentRate_change" //i.municipalAssetsTotalQuantil population 
        
//Regression    
    qui eststo spezifikation1: reg growth_assets `independent' `firmControls' `stateControls', vce(cluster statekz)
    qui eststo spezifikation2: reghdfe growth_assets `independent' `firmControls' `stateControls', absorb(i.year i.industry_sic_2_digit) vce(cluster statekz)
    qui eststo spezifikation3: reghdfe growth_assets `independent' `firmControls' `stateControls', absorb(i.year##i.industry_sic_2_digit) vce(cluster statekz)
    qui eststo spezifikation4: reghdfe growth_assets `independent' `firmControls' `stateControls', absorb(i.year##i.industry_sic_2_digit i.municipalId) vce(cluster statekz)
//Regression output    
    esttab spezifikation1 spezifikation2 spezifikation3 spezifikation4, b("%-8.5f") t ///
    stats(N r2_a, labels("N" "Adj. R-Square") fmt("%-8.0fc" "%-8.3f")) ///
    varwidth(22)  ///
    nonumbers mtitles("No FE" "Year Ind" "Year##Ind" "Year##Ind Mun" "Model 5" "Model 6" "Model 7" "Model 8") ///
    nonotes addnote("t-values werden in Klammern angegeben.")
But somehow my Diff in Diff graph looks like this:
Array
I am trying to understand why the log total assets growth mean of the control group also decreases after the event. I am using the following code to generate the graph. I am new to Stata so please forgive me if there are more effective ways to achieve the same (actually please tell me if there are).
Code:
foreach group in 1 0 {
    foreach time in "L5" "L4" "L3" "L2" "L1" "L0" "F1" "F2" "F3" "F4" "F5" { 
       qui: sum `time'.growth_assets if hebesatzIncreaseDummy == `group', de
        scalar group`group'Time`time' = r(mean)
    }    
}
//Clear Dataset
drop _all
//Create Graph Dataset out of Scalars
set obs 22
gen treated = 0
gen eventtime = 0
gen growth_assets_mean = 0
scalar obs = 1
foreach group in 1 0 {
    foreach time in "L5" "L4" "L3" "L2" "L1" "L0" "F1" "F2" "F3" "F4" "F5" {
        replace treated = `group' in `=obs'
        
        replace eventtime = real(substr("`time'", 2, 2)) in `=obs'
        if (substr("`time'", 1, 1) == "L") {
            replace eventtime = eventtime *-1 in `=obs'
        }
            
        replace growth_assets_mean = group`group'Time`time' in `=obs'
        
        scalar obs = `=obs' + 1
    }    
}
//Graph
twoway (line growth_assets_mean eventtime if treated == 1) (line growth_assets_mean eventtime if treated == 0), legend(lab (1 "Treated firms") lab(2 "Non treated firms")) ylabel(#6) xlabel(#11, grid)
I would be very thankful for any help!
Best regards,
Andres
0 Response to How to control for something within a Diff in Diff Graph
Post a Comment