Announcement

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

  • Parallel trend assumption plot

    Hello everyone,

    I am currently working on an DID analysis of my dataset and require to plot a parallel trend assumption plot.

    My data is structured as followed:

    Code:
    . list CompanyName time xDivPerShare treated in 1/40
    
    
    +-----------------------------------------------------+
    | CompanyName      time     xDivPe~e           treated |
    |-----------------------------------------------------|
    1. | Comp1          2007    0.25                   1 |
    2. | Comp1          2008    0.4                 1 |
    |-----------------------------------------------------|
    11. | Comp2        2007     0                   1 |
    12. | Comp2        2008     0.13              1 |
    |-----------------------------------------------------|
    21. | Comp3       2007      .11                0 |
    22. | Comp3       2008      .7                  0 |
    |-----------------------------------------------------|

    The goal is to plot the mean of the variable DivPerShare for the groups where treated == 0 and treated == 1 respectively for the years 2007-200x. I inserted just a few lines of the dataset here.
    I found out that I most likely have to use something like -collapse- in order to get something like a mean for each year over all companies in group "treated == 0" before i can plot that.

    I went through this thread https://www.statalist.org/forums/for...end-assumption
    already but somehow could not understand how to apply this to my specific case.

    If you need more information I am happy to provide more details.
    Maybe someone here has some experience with that and can help me out.
    Thank you in advance for any help!

    Best
    Last edited by Noah Woelki; 04 Jun 2022, 11:16.

  • #2
    Hi, following your example:

    Code:
    clear
    input str10 CompanyName  float(time xDivPerShare treated)
    comp1 2007 0.25 1
    comp1 2008 0.4  1
    comp2 2007 0    1
    comp2 2008 0.13 1
    comp3 2007 0.11 0
    comp3 2008 0.7  0 
    end
    
    collapse (mean) xDivPerShare, by(time treated)
    sort treated time
    tw line xDivPerShare time if treated==0 || line xDivPerShare time if treated==1, xlabel(#2)

    Comment


    • #3
      Daniel PV thank you so much that is exactly what I was looking for!

      Could you just briefly explain what the xlabel(#2) does to the graph, or what it is used for, as I am not really familiar with plotting in stata?

      Thanks again

      Comment


      • #4
        Sure, I add xlabel(#2) to display only 2 labels on the x-axis. I recommend you to see the help file
        Code:
        help twoway
        to see in more detail the syntax of this graph.

        Comment

        Working...
        X