Announcement

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

  • reghdfe for an event study, standard deviations widens as we move from the base year

    Dear friends,
    I have a panel dataset which I am running reghdfe on it (for analyzing an event which happened in 2009). My base year is 2009. There are some treated counties and some control counties. The years before 2009 are before treatment period, and the years after are post treatment. I am analyzing the effect of this event on population share of different races in treated counties (share_white, share_black, share_hispanic, share_asian). However, surprisingly, the standard deviations gets consistently larger as I move away from 2009. I have double checked my dataset, it seems ok. Since this problem happens for the share of all races, I assume somewhere in my code I am making a mistake. Could you please help me?
    Stata 16

    This is my code:
    Code:
        u "C:/Users/fatem/Desktop/test.dta", clear    
        drop if missing(treated_counties)
        g coef = .
        g sd = .
        summ ib2009.year
        reghdfe share_white c.treated_counties##ib2009.year unemloyment_rate ///
                lntot_pop, ab(county_fips year) vce(cl county_fips)
        sum year if e(sample), de
        foreach yr of numlist `r(min)'/`r(max)' {
            summ share_white if year==`yr'
            replace coef = _b[c.treated_counties#`yr'.year] if year == `yr'
            replace sd = _se[c.treated_counties#`yr'.year] if year == `yr'
            }
        collapse (mean) coef sd, by(year)
        g up90 = coef + 1.67*sd
        g down90 = coef - 1.67*sd
        g up95 = coef + 1.95*sd
        g down95 = coef - 1.95*sd
        gr tw (rbar up95 down95 year, barwidth(0.25) fi(25) lw(none))  /*
        */ (rbar up90 down90 year, barwidth(0.25) fi(75) lw(none)) /*
        */ (connected coef year, ms(O) mc(gs6) yline(0, lp(solid)) yline(0, lp(solid)) xline(2009, lc(red) lp(solid))), /*
        */ legend(order(3 2 1) label(1 "95% CI") label(2 "90% CI") label(3 "Point Estimates") ring(0) position(1)) /*
        */ xlabel(2004(2)2016) /*
        */ title("OLS estimate of Share of White population", size(small)) xtitle("") /*
        */ note("County, year fe are used.") 
        graph export "C:/Users/fatem/Desktop/3whiteshare_ols_eventstudy_borderingcounties.png", replace


    This is 100 observations of my data:
    columns: county_fips year treated_counties unemployment_rate lntot_pop share_white coef sd
    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input float county_fips int year byte treated_counties float(unemloyment_rate lntot_pop share_white coef sd)
    1005 2004 0  .07096532 10.250157  .4902252 -.00017331526   .001538591
    1005 2005 0  .05740913 10.240924  .4862811  -.0003519282  .0012224042
    1005 2006 0  .05628676 10.234983  .4811744  -.0006008844   .000909168
    1005 2007 0  .06417061 10.231243  .4767806  -.0004757014  .0006120544
    1005 2008 0  .09100737  10.23308  .4738205 -.00032280505  .0003547888
    1005 2009 0  .13163717 10.227634  .4721047             0            0
    1005 2010 0  .12144046 10.215557  .4704849  -.0003929117 .00027636442
    1005 2011 0   .1144976 10.216252   .471182  .00010996138   .000509118
    1005 2012 0  .11773489 10.209942  .4704107 -.00003285825  .0006363138
    1005 2013 0  .10378188  10.20159  .4674534   .0004268815  .0007247712
    1005 2014 0  .10486511 10.194963  .4685072   .0008051821  .0008610787
    1005 2015 0  .08928987 10.177324 .46657795   .0009634383   .001008456
    1005 2016 0  .08351332 10.159214   .465851   .0006382616  .0011573451
    1017 2004 0  .06914605 10.476245  .5950145 -.00017331526   .001538591
    1017 2005 0  .05696591 10.471044  .5924771  -.0003519282  .0012224042
    1017 2006 0  .05786435  10.46153  .5904135  -.0006008844   .000909168
    1017 2007 0  .06624992 10.458722   .587999  -.0004757014  .0006120544
    1017 2008 0  .14887828  10.45054 .58660996 -.00032280505  .0003547888
    1017 2009 0   .1811279 10.445347  .5849523             0            0
    1017 2010 0  .14612462   10.4372 .58627766  -.0003929117 .00027636442
    1017 2011 0  .11847217 10.434587  .5868121  .00010996138   .000509118
    1017 2012 0  .10092349   10.4367 .58076155 -.00003285825  .0006363138
    1017 2013 0  .08091463 10.437785  .5759707   .0004268815  .0007247712
    1017 2014 0  .06660578 10.433057  .5691026   .0008051821  .0008610787
    1017 2015 0  .06078051  10.43385 .56597334   .0009634383   .001008456
    1017 2016 0   .0547853 10.426498  .5636892   .0006382616  .0011573451
    1019 2004 0  .04729954   10.1221  .9312493 -.00017331526   .001538591
    1019 2005 0  .04320679  10.12787  .9316048  -.0003519282  .0012224042
    1019 2006 0  .04189144   10.1451  .9317129  -.0006008844   .000909168
    1019 2007 0  .04262404  10.14851  .9308887  -.0004757014  .0006120544
    1019 2008 0  .05933828 10.151752  .9305664 -.00032280505  .0003547888
    1019 2009 0  .10712761  10.16022  .9299141             0            0
    1019 2010 0  .10457003  10.16462  .9307609  -.0003929117 .00027636442
    1019 2011 0  .09622592 10.165583  .9292117  .00010996138   .000509118
    1019 2012 0   .0822841  10.16435  .9279304 -.00003285825  .0006363138
    1019 2013 0  .06715239 10.166698  .9286373   .0004268815  .0007247712
    1019 2014 0  .05777154 10.161998  .9293823   .0008051821  .0008610787
    1019 2015 0  .05488681 10.155763  .9283966   .0009634383   .001008456
    1019 2016 0  .05070723 10.156927  .9284024   .0006382616  .0011573451
    1029 2004 0  .05217521  9.570739  .9394658 -.00017331526   .001538591
    1029 2005 0  .03914484  9.572759   .938892  -.0003519282  .0012224042
    1029 2006 0  .03475775  9.584521  .9365112  -.0006008844   .000909168
    1029 2007 0  .03724796  9.602315  .9376309  -.0004757014  .0006120544
    1029 2008 0  .05246302   9.60737  .9385505 -.00032280505  .0003547888
    1029 2009 0  .09324511  9.610324  .9365867             0            0
    1029 2010 0  .09842585  9.616072  .9370834  -.0003929117 .00027636442
    1029 2011 0   .0963125  9.610994  .9351554  .00010996138   .000509118
    1029 2012 0  .08404656  9.608378  .9355229 -.00003285825  .0006363138
    1029 2013 0  .07776824  9.614071  .9345532   .0004268815  .0007247712
    1029 2014 0 .065654844  9.617737  .9329962   .0008051821  .0008610787
    1029 2015 0  .06055791  9.610659  .9333244   .0009634383   .001008456
    1029 2016 0   .0599512  9.607168  .9334947   .0006382616  .0011573451
    1049 2004 0  .05704311  11.11632   .877862 -.00017331526   .001538591
    1049 2005 0  .05051997  11.12423   .868956  -.0003519282  .0012224042
    1049 2006 0  .04145784 11.134516   .859362  -.0006008844   .000909168
    1049 2007 0  .04352722 11.148362   .852671  -.0004757014  .0006120544
    1049 2008 0  .06021702 11.159502   .843168 -.00032280505  .0003547888
    1049 2009 0  .13113375 11.168518  .8352337             0            0
    1049 2010 0  .12400544 11.172307  .8296431  -.0003929117 .00027636442
    1049 2011 0   .1170663 11.175142  .8260181  .00010996138   .000509118
    1049 2012 0  .09266315  11.16921  .8269711 -.00003285825  .0006363138
    1049 2013 0   .0773155 11.168757  .8260606   .0004268815  .0007247712
    1049 2014 0  .06838638 11.169914  .8261065   .0008051821  .0008610787
    1049 2015 0  .06101045  11.17135  .8259199   .0009634383   .001008456
    1049 2016 0  .06083598 11.172068  .8234575   .0006382616  .0011573451
    1067 2004 0  .05533492  9.722685  .6595974 -.00017331526   .001538591
    1067 2005 0  .04282454  9.726273  .6628462  -.0003519282  .0012224042
    1067 2006 0  .03992547    9.7382  .6666667  -.0006008844   .000909168
    1067 2007 0  .05490144  9.747301  .6691022  -.0004757014  .0006120544
    1067 2008 0  .07977787  9.748528  .6724269 -.00032280505  .0003547888
    1067 2009 0  .10254607  9.755161  .6791742             0            0
    1067 2010 0  .10763936  9.758057  .6832244  -.0003929117 .00027636442
    1067 2011 0  .09671207  9.762903  .6853312  .00010996138   .000509118
    1067 2012 0   .0849794   9.74987  .6855177 -.00003285825  .0006363138
    1067 2013 0   .0781295   9.74847   .688405   .0004268815  .0007247712
    1067 2014 0  .07469063  9.745312  .6933935   .0008051821  .0008610787
    1067 2015 0  .06848702  9.746658  .6933965   .0009634383   .001008456
    1067 2016 0  .06525653  9.744609  .6955808   .0006382616  .0011573451
    1069 2004 0  .04621209 11.435968  .7153673 -.00017331526   .001538591
    1069 2005 0   .0379923 11.450018  .7108719  -.0003519282  .0012224042
    1069 2006 0 .033966463 11.470498  .7092002  -.0006008844   .000909168
    1069 2007 0  .03399044 11.489933  .7059666  -.0004757014  .0006120544
    1069 2008 0  .05061683 11.504722  .7010072 -.00032280505  .0003547888
    1069 2009 0  .08507667 11.517913  .6971841             0            0
    1069 2010 0  .09043755 11.530766  .6951375  -.0003929117 .00027636442
    1069 2011 0  .08605804 11.537705  .6926416  .00010996138   .000509118
    1069 2012 0   .0775488 11.546457  .6886665 -.00003285825  .0006363138
    1069 2013 0  .07020079  11.54917   .687292   .0004268815  .0007247712
    1069 2014 0  .06748629  11.55422  .6833788   .0008051821  .0008610787
    1069 2015 0  .06266877 11.555276  .6829362   .0009634383   .001008456
    1069 2016 0  .05802874 11.555553  .6798908   .0006382616  .0011573451
    1071 2004 0  .06742071 10.887904  .9234189 -.00017331526   .001538591
    1071 2005 0  .04995319 10.884292  .9228043  -.0003519282  .0012224042
    1071 2006 0  .04443952  10.88712   .921433  -.0006008844   .000909168
    1071 2007 0  .04611579  10.88431  .9206495  -.0004757014  .0006120544
    1071 2008 0 .063760884 10.887904  .9182999 -.00032280505  .0003547888
    1071 2009 0  .11711815 10.886707  .9179215             0            0
    1071 2010 0   .1163593 10.881946  .9170034  -.0003929117 .00027636442
    1071 2011 0  .10215232 10.882565  .9165477  .00010996138   .000509118
    1071 2012 0  .08800505 10.880064  .9163011 -.00003285825  .0006363138
    end
    Click image for larger version

Name:	3whiteshare_ols_eventstudy_borderingcounties.png
Views:	1
Size:	100.7 KB
ID:	1733145

  • #2
    Fatemeh:
    your data excerpt does not allow to detect any issues.
    In addition, as per your graph, you seem to be concerned about the widening/shrinking of the 95% CI concerning the coefficient for the white share of the population.
    Some more details may be beneficial. Thanks.
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment

    Working...
    X