Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Difference in Difference regression/ Two-Way fixed effects OLS

    Hello,
    I was wondering if someone could help me out here a little bit. I'm essentially conducting an analysis on the effect of a certain law on the gender pay gap in the public sector vs private sector. (So there's 2 DiD here, male vs female +public vs private)

    My code is as follows:
    Code:
    use "lfs_2013.dta"
    append using "lfs_2014.dta"
    append using "lfs_2015.dta"
    append using "lfs_2016.dta"
    append using "lfs_2017.dta"
    append using "lfs_2018.dta"
    append using "lfs_2019.dta"
    append using "lfs_2020.dta"
    append using "lfs_2021.dta"
    append using "lfs_2022.dta"
    append using "lfs_2023.dta"
    
    
    keep if (lfsstat==1 | lfsstat==2)
    keep if !missing(survyear, survmnth, sex, hrlyearn, ftptmain)
    drop if (naics_18==1 | naics_18==2 | naics_18==3 | naics_18==10 | naics_18==13 | naics_18==14 | naics_18==15 | naics_18==16 |naics_21==1 | naics_21==4 | naics_21==12 | naics_21==16 | naics_21==17 | naics_21==18 | naics_21==19 | naics_21==5)
    drop if ftptmain==2
    
    
    gen treat=0
    replace treat=1 if (survyear<=2016 & (naics_18==9 | naics_18==18)) | (survyear>2016 & (naics_21==11 | naics_21==21))
    
    
    
    gen date= survyear+ (survmnth-1)/12     
    gen public= (naics_18==9 |naics_18==18 |naics_21==21 | naics_21==11)
    gen female= (sex==2)
    gen post= (date>=2019)     // Law passed. 
    gen DD= public *post
    gen DDF= DD *female
    gen logwage= ln(hrlyearn+1)
    egen date2= group(date)
    regress logwage i.treat i.date2 i.DD i.female i.DDF , robust
    outreg2 using DiD_Passed, word


    I'm trying to test if the parallel trends assumption is valid and obtain an image as such:

    Click image for larger version

Name:	five_estimators_example.png
Views:	1
Size:	92.9 KB
ID:	1741074



    I found the code for the above as :
    Code:
    reghdfe Y F*event L*event, a(i t) cluster(i)
    event_plot, default_look stub_lag(L#event) stub_lead(F#event) together graph_opt(xtitle("Days since the event") ytitle("OLS coefficients") xlabel(-14(1)5) ///
        title("OLS"))
    . but have no idea how to incorporate that to my dataset.

    Any help will be much appreciated!

  • #2
    No need for a formal test unless you're doing asymptotic analysis, parallel trends looks just fine here. Naturally, naive OLS does worst.

    Comment

    Working...
    X