Announcement

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

  • Plotting pre-treatment parallel trend

    I am trying to draw a common pre-trend graph for a diff-in-diff design. My treatment group is made of one only state, while the control group is made of three states. The data are a panel so that I have obseervations for each unit (state) over the same period of time. I'll post here a portion of it

    Code:
     state  year   cases     pop
    ACT    1971     35     151169  
    ACT    1972     57     159792
    ACT    1973     35     173306
    ACT    1974     34     186241
    ACT    1975     67     199007
    ACT    1976     44     207740
    ACT    1977     145    213688
    ACT    1978     180    217981
    ACT    1979     280    220797
    ACT    1980     269    224291
    NSW    1971    3943    4725503
    NSW    1972    3698    4795106
    NSW    1973    3356    4841898
    NSW    1974    3606    4894053
    NSW    1975    3517    4932016
    NSW    1976    3535    4959588
    NSW    1977    3807    5001888
    NSW    1978    4180    5053790
    NSW    1979    3656    5111130
    NSW    1980    3643    5171527
    NSW    1981    3841    5234889
    NT     1971    412     85735
    NT     1972    404     92081
    NT     1973    524     97127
    NT     1974    563     102924
    NT     1975    494     92869
    NT     1976    515     98228
    NT     1977    560     103938
    NT     1978    719     109980
    NT     1979    911     114149
    NT     1980    722     118245
    NT     1981    970     122616
    Qld    1971    1852    1851485
    Qld    1972    2039    1898478
    Qld    1973    2192    1951951
    Qld    1974    1952    2008340
    Qld    1975    1718    2051362
    Qld    1976    1492    2092375
    Qld    1977    1678    2129839
    Qld    1978    2107    2172047
    Qld    1979    1695    2214771
    Qld    1980    1838    2265935
    Qld    1981    1353    2345208
    Now what I would like to plot are just two lines, one for the treated group and one for the control group (three of those state in aggregate, e.g. NSW, NT and Qld). What I need to plot is the ratio "cases/pop".

    My code by now is

    Code:
    twoway (line log_GON year if treated == 1, lcolor(red) xline(1995)) (line log_GON year if treated== 0, lcolor(blue))
    where treated variable is equal to 1 for state ACT and equal to 0 for state NSW, NT and Qld. But the result is a plot with 4 lines, one for each state instead of one for the treated group and one for the control group in aggregate

    What is the more meaningful way of doing it? Should I manually aggregate the data (i.e. summing cases and pop by year and create a new "control" state) or is there a easier way of doing it?
Working...
X