Announcement

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

  • Question about graphing observed means in parallel trends diagnostics after didregress

    Hello Statalist community,

    I’m having trouble understanding the graphical diagnostics for the parallel trends assumption after running the didregress command, as shown in the Stata documentation here: https://www.stata.com/manuals/causaldidregress.pdf.

    According to the documentation, a visual diagnostic of this assumption can be obtained by plotting the means of the outcome over time for both groups, or by visualizing the results of the linear-trends model. The estat trendplots command displays two graphs: one for the observed means and another for the linear-trends model.

    Initially, I assumed that the graph of observed means could be generated using the following commands:

    collapse (mean) satis, by(procedure month)
    twoway connected satis month if procedure == 0 || connected satis month if procedure == 1

    But the graph is different in that the treatment group doesn't have observations from January to March and the values of control group are higher than trendplots.
    Click image for larger version

Name:	Screenshot 2025-06-02 at 3.22.30 PM.png
Views:	1
Size:	36.1 KB
ID:	1778398



    I then tried plotting the means using a model-based approach:

    regress satis i.procedure i.month
    margins, at(procedure=0 month=(1(1)7) )
    margins, at(procedure=1 month=(1(1)7) )

    But the predicted values from this approach differ from those shown in the estat trendplots graph.

    Is there a way to reproduce the observed means graph shown in estat trendplots using separate commands?

    Thank you in advance for your help.
    Click image for larger version

Name:	Screenshot 2025-06-02 at 3.17.34 PM.png
Views:	1
Size:	64.4 KB
ID:	1778397

    Last edited by Sangno Lee; 02 Jun 2025, 14:40.

  • #2
    In the first one, I suspect that procedure does not measure ever treated observations, which is why there's no graph pre for the treated. create a variable == 1 if the unit is ever treated. Might make sense to center as well, so the lines are of the same scale.

    Comment


    • #3
      Thank you, Your response was very helpful. I appreciate your support!

      bys hospital: egen evertreated = max(procedure)
      collapse (mean) satis, by(evertreated month)
      twoway connected satis month if evertreated == 0 || connected satis month if evertreated == 1

      Comment


      • #4
        you could use lgraph, which collapses the data behind the scenes but does not disturb your data.

        ssc install lgraph
        lgraph satis month, by(evertreated)

        Comment

        Working...
        X