Announcement

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

  • Seasonality line graph

    Hi, I have a panel dataset for 308 authorities from 2014Q1 to 2018Q4. My dependent variable is HDRR (recycling rate).

    I was wondering if someone knew the code for me to graph average HDRR for each quarter, to create a line graph?
    Or is an alternative way to showing seasonality in a graph in stata?

    Thanks

  • #2
    Let's suppose the dates are in qdate

    Then

    Code:
    egen mean = mean(HDRR), by(qdate)

    averages across authorities for each date. The results will be a mess but some variation on

    Code:
    sort authority qdate 
    
    line HDRR qdate, c(L) lc(gs12) lw(vthin) || line mean qdate , lw(thick)
    might help and might indicate whether

    1. a transformed scale would work better

    2. a summary other than, or additional to, the mean would help

    Comment


    • #3
      You need to collapse the data first to get quarterly averages. Below, subtitute time with the name of your time variable and adjust the x-axis labels appropriately.

      Code:
      preserve
      collapse HDRR, by(time)
      tw line HDRR time, xlabel(`=tq(2014q1)'(3)`=tq(2018q4)')
      restore
      NB. Crossed with Nick's helpful reply.

      Comment

      Working...
      X