Announcement

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

  • DiD model on heterogeneous data

    Hi everyone,

    I’m working with panel data where each patient (patient_id) is followed from 2010–2020.
    The treatment (disease_on) switches from 0 to 1 starting in the year a patient develops a certain disease, and stays 1 afterward. Controls are the ones who never develop the disease and (disease_on) is 0 during all years.

    Here’s what I did so far:
    • Matched treated and untreated patients year-by-year using kmatch ps ... wor att nn(1) generate, keeping only matched controls
    • Then ran:
    • xthdidregress ra (outcome variable) (disease_on), group(patient_id)
      which estimates cohort- and time-specific ATETs.
    • I can plot event-time effects using estat atetplot, ci, and I can test pretreatment differences with estat ptrends.
    What I’d like to do now is produce a graph comparing average outcomes (outcome variable) for treated vs. control patients around the disease year, similar to a “two-line event-time plot” with a vertical line at event time = 0.

    I have tried estate trendplot but its not working because the year that the disease happens is not the same for all patients (heterogeneous).

    What’s the correct way in Stata to aggregate matched treated and control observations so I can plot smooth mean trajectories around the event (say −5 to +5 years)?

    Any guidance or example code for producing a clear “treated vs. control around the event year” graph after matching and heterogeneous DID would be really appreciated.

    Thanks!
    Last edited by Mido Mido; 06 Nov 2025, 10:48.
Working...
X