Announcement

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

  • Using coefplot to plot estimates from different methods (ie.TWFE and IW estimators) together on one graph

    I am using a panel data, try to estimate dynamic policy effects by two methods: one is the classic dynamic-TWFE specification and the second one is IW estimators provided by Sun & Abraham (2021).
    The ultimate ideal graph that I would like to have are similar as follow: Basically, event-study plot by two methods on the same graph.
    Click image for larger version

Name:	ESplot_qje.png
Views:	1
Size:	314.1 KB
ID:	1679204


    I made the graphs for these two methods separately, but cannot combine them together.

    Code:
    * dynamic TWFE regression
    reghdfe y4 g_11-g_2 g0-g9 $controlsAll , absorb(Li year) cluster(Li)
    est store TWFE
    
    * make graph
    coefplot TWFE, keep(g_* g*) vertical ///
    yline(0,lcolor(edkblue*0.8)) ///
    addplot(line @b @at, lcolor(edkblue*0.8)) ///
    ciopts(lpattern(dash) recast(rcap) msize(medium)) ///
    xlabel(,labsize(*0.75) angle(45)) 
    
    
    ** IW estimator by Sun & Abraham
    eventstudyinteract y4 g_11-g_2 g0-g9, cohort(_nfd) control_cohort(never) covariates($controlsAll) absorb(i.Li i.year) vce(cluster Li)
    
    * make graph
    matrix C = e(b_iw)
    mata st_matrix("A",sqrt(st_matrix("e(V_iw)")))
    matrix C = C \ A
    matrix list C
    
    coefplot matrix(C[1]), se(C[2]) vertical ///
    yline(0,lcolor(edkblue*0.8)) ///
    addplot(line @b @at, lcolor(edkblue*0.8)) ///
    ciopts(lpattern(dash) recast(rcap) msize(medium)) ///
    xlabel(,labsize(*0.75) angle(45))
    The two graphs looks like follows: Top one is from TWFE, bottom one is from IW.
    Click image for larger version

Name:	Graph1.png
Views:	1
Size:	211.8 KB
ID:	1679205


    Click image for larger version

Name:	Graph2.png
Views:	1
Size:	226.3 KB
ID:	1679206



    I tried addplot. Failed. seems this code only apply for twoway style graphs.
    I am not sure does it to do with the second graph is made through a matrix and the first one is from a regression ?

    Btw, this is my first post, how do I adjust pictures size smaller (it looks so much bigger than the text now)?...😅


    I would really appreciate any help from you!

    Best,
    Julie



  • #2
    There does not appear to be any conceptual difficulty in plotting stored estimates together with those from a matrix. So just check where in the process you are going wrong. Note the importance of a reproducible example in illustrating a point, as below. Review FAQ Advice #12 for suggestions on how to post more effectively.

    Code:
    sysuse auto, clear
    regress mpg weight i.rep78
    mat res= r(table)["b".."se", 1...]
    est sto A
    set scheme s1color
    coefplot (matrix(res), drop(_cons) se(2)) (A, drop(_cons)), saving(g3, replace)
    Click image for larger version

Name:	Graph.png
Views:	1
Size:	25.9 KB
ID:	1679225

    Comment

    Working...
    X