Announcement

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

  • Treatment Variation Plot

    Hello Statalist!

    I was wondering if it would be possible for Stata to plot this kind of variation figure.
    This figure shows how the treatment was assigned over time for each unit. What command can I use to make this kind of plot?
    Thank you in advance.


    Attached Files

  • #2
    It's essentially a scatter plot. You would need to play with choosing marker symbol and marker size.

    Comment


    • #3
      Alternatively you could view this as a bar plot:

      Code:
      // some example data
      clear
      set seed 123
      set scheme s1mono
      set obs 200
      gen id = _n
      gen treatment = _n < 101
      gen addopt = floor(runiform()*24) if treatment == 1
      
      // variables for plotting
      gen lbn = 0
      gen ubn = cond(treatment==1, addopt, 25)
      gen lbt = addopt if treatment == 1
      gen ubt = 25 if treatment == 1
      
      gsort treatment -addopt
      gen id2 = _n
      
      // create labels for the x-axis
      forvalues i=0/24 {
          local labs = `"`labs' `=`i'+.5' "`i'""'
      }
      
      // the plot
      twoway rbar lbn ubn id2, lwidth(none) horizontal fcolor(gs14) || ///
             rbar lbt ubt id2, lwidth(none) horizontal fcolor(gs8 )    ///
             legend(order(1 "control" 2 "treated"))                    ///
             ylabel(none) ytitle(unit)                                 ///
             xlab(`labs', noticks) xtick(0/25)
      Click image for larger version

Name:	Graph.png
Views:	1
Size:	41.6 KB
ID:	1691138
      ---------------------------------
      Maarten L. Buis
      University of Konstanz
      Department of history and sociology
      box 40
      78457 Konstanz
      Germany
      http://www.maartenbuis.nl
      ---------------------------------

      Comment


      • #4
        No need to go nuts here, just use panelview! It works really well in staggered adoption settings for DD

        Comment

        Working...
        X