Announcement

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

  • Parallel trend plot

    Dear Statalisters,

    I am conducting a difference-in-difference analysis with my bank level data with the pandemic as an exogenous shock. The analysis is going great and this is only a minor issue, however, I can't seem to think of, or rather do not know how to find a way to plot a parallel trends graph that is informative. I use the built in estat trendplots feature in Stata 17 following the xtdidregress function which is great and provides what's needed albeit in not most aesthetically pleasing manner. However, the issue is my outcome variables are change variables and are very tiny (talking +/- 0.03) pre treatment and post treatment experience a huge drop (-0.27) which expands the graph along Y dimension substantially. Since the difference between control and treatment group is very minor this graph does not provide too insightful information (see the graph #1 below).

    What I am looking for is an idea or suggestion on how to to make it more understandable, perhaps having the difference in means in each quarter as one line with a 95% confidence intervals plotted next to that line to see whether the trends are at zero essentially showing that they are parallel (essentially what estat ptrends does but graphically). Another solution I can come up with is having distorted Y-axis, that is, have it be shortened below the X-axis to reduce the difference, however, it might be misleading and I am not sure it is doable in Stata.

    I've looked through Google and Statalist for solutions, however, they do not seem to provide the solution that I am looking for and would be comfortable in using for my thesis. I did plot one solution using margins function as suggested by Clyde Schechter on another thread here on this forum, however, I am not sure what to make of it as I struggle to understand what the graph is showing (see graph #2).


    Graph #1:
    Click image for larger version

Name:	Screenshot 2021-11-07 at 11.06.03.png
Views:	1
Size:	532.8 KB
ID:	1635222

    Graph #2:
    Click image for larger version

Name:	Screenshot 2021-11-07 at 11.05.48.png
Views:	1
Size:	339.9 KB
ID:	1635221

    What I think I am looking for is something closer to this graph, except for instead of confidence bands, have confidence interval lines go:



    Any help or any suggestions would be greatly appreciated. Thank you so much in advance!

  • #2
    You can use coefplot from SSC to plot coefficient estimates and CIs.
    First, generate event time (+ 100 because Stata doesn't like negative values in factor vars)
    Code:
    gen event = year - year_of_adoption + 100
    Second, estimate dynamic specification and store estimates,
    Code:
    xtreg y ib99.event i.year ,fe i(id) cluster(id)
    eststo m
    Third, plot coefficient estimates and CIs,
    Code:
    coefplot m ,keep(*.event) vert rename(*.event="") xtitle(event time + 100)

    Comment


    • #3
      Thank you Øyvind!

      It is closer to what I am looking for, however, not quite what I had in mind. Again, the values are small and there isn't a huge variation in them so the bands are very small for some quarters. I guess what I am after is a difference between the means (or rather coefficients?) on both of my control and treatment groups that is plotted against a zero with 95% confidence intervals to see whether the parallel trends assumption holds or not.

      What I have in mind is it would plot the change in differences between the two means which are shown in graph 1 above that are supposed to show parallel trends (for example, in the first quarter the difference between two means was, say, 0.2, so if parallel trends were to hold this difference should remain constant at 0.2). What I guess would be a great way to illustrate such graph in a smoother way would be to show the how the difference between the means changes and the 95% confidence interval that shows whether this difference is different from zero. If it is not different from zero then (and correct me if I am wrong) the parallel trends assumption holds because the trends move in parallel.

      Such a graph would be a viable option because in the Stata graph for this particular data show the very little difference to tell whether there is a parallel trend or not.

      Here is my terrible drawing of what I have in mind:

      Click image for larger version

Name:	Screenshot 2021-11-07 at 13.47.36.png
Views:	1
Size:	81.4 KB
ID:	1635234

      Y-axis shows the difference between the means from Graph #1 above also represented by the black dots and corresponding line that connects them. X-axis is the time dimension, which shows the difference each quarter. The red lines are the 95% confidence intervals that the difference between the trends is 0 and in this made up case it would barely suggest no difference and therefore parallel trends assumption to be valid.

      Comment


      • #4
        Hello,
        I am conducting a Difference-in-Difference in which i want to predict the impact of a policy which implemented in 2016. I want to plot parallel trend graph but as i am currently working on STATA 16 so it is bit difficult for me to find the right command for plotting parallel trend graph after analysis.
        The command I am using is
        Code:
        gen diff =treat*post  
        xtset treat year  
        xtreg tti diff loggrdp logpopden logvkt cng petrol i.post, robust cluster(treat)
        The Data set I am using is given bellow
        Code:
        * Example generated by -dataex-. To install: ssc install dataex
        clear
        input str3 area int year float(loggrdp logvkt logpopden cng petrol tti) byte(treat post)
        "DHK" 2019 5.08289 4.89612 4.10358 .516 1.12 3.97927 1 1
        "DHK" 2018 5.03987 4.88075 4.08819  .48 1.12 3.68113 1 1
        "DHK" 2017  4.9995  4.8653 4.07275  .48 1.12   3.383 1 1
        "DHK" 2016 4.94728 4.84986 4.05731  .42 1.12 3.08486 1 1
        "DHK" 2015 4.89229 4.83441 4.04186  .42  1.3 2.78673 1 0
        "DHK" 2014 4.83983 4.81897 4.02641 .201  1.3 2.68755 1 0
        "DHK" 2013 4.77812 4.80352 4.01098 .201 1.15 2.58836 1 0
        "DHK" 2012 4.72709 4.78808 3.99552 .201 1.15 2.48918 1 0
        "DHK" 2011 4.71144 4.77263 3.98009 .201 1.09    2.39 1 0
        "DHK" 2010 4.66381 4.75719 3.96466 .201 1.09   2.331 1 0
        "DHK" 2009  4.6127 4.74174  3.9492 .201 1.17   2.272 1 0
        "CTG" 2019 4.56001 3.90558 3.63007 .516 1.12   3.255 0 1
        "CTG" 2018   4.517 3.89674 3.62123  .48 1.12 3.09642 0 1
        "CTG" 2017 4.47662 3.88809 3.61258  .48 1.12 2.93784 0 1
        "CTG" 2016  4.4244 3.87935 3.60385  .42 1.12 2.77925 0 1
        "CTG" 2015 4.36941 3.87073 3.59522  .42  1.3 2.62067 0 0
        "CTG" 2014 4.31695 3.86212 3.58661 .201  1.3 2.49246 0 0
        "CTG" 2013 4.25524 3.85344 3.57793 .201 1.15 2.36425 0 0
        "CTG" 2012 4.20421 3.84479 3.56928 .201 1.15 2.23604 0 0
        "CTG" 2011 4.18856 3.83617 3.56066 .201 1.09 2.10783 0 0
        "CTG" 2010 4.14094 3.82747 3.55197 .201 1.09 1.97962 0 0
        "CTG" 2009 4.08982 3.81882 3.54331 .201 1.17 1.85141 0 0
        end

        Comment


        • #5
          Code:
          eststo m: reg tti ib2015.year##c.treat
          coefplot m, keep(*year#*) base omitted vert ylabel(-0.25(.25)1) xlabel(1 "2009" 3 "2011" 5 "2013" 7 "2015" 9 "2017" 11 "2019")

          Comment


          • #6
            Thank you for your response but when i tried to execute the command, it shows
            command eststo is unrecognized
            command coefplot is unrecognized
            Last edited by Sakib Nazmus; 03 Feb 2022, 10:33.

            Comment


            • #7
              You need estout and coefplot in order to run these. Sakib Nazmus

              Comment


              • #8
                Originally posted by Sakib Nazmus View Post
                Thank you for your response but when i tried to execute the command, it shows
                command eststo is unrecognized
                command coefplot is unrecognized
                Hi Sakib,

                Both estout and coefplot are from SSC, so you need to install them before use. Type: ssc install estout and ssc install coefplot

                Comment


                • #9
                  I am getting @1 kind of graph where i want graph like @2
                  @1
                  Click image for larger version

Name:	@1.png
Views:	1
Size:	26.5 KB
ID:	1648204

                  @2
                  Click image for larger version

Name:	@2.png
Views:	1
Size:	92.0 KB
ID:	1648205

                  Comment

                  Working...
                  X