Announcement

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

  • Creating Monthly Averages Across Years

    Dear all,

    I have an unbalanced panel of large T small N data filled with online prices. As they are seasonal, I'm trying to de-seasonalize such data by smoothing the data via an linear MA smooth. Next, I would like to have a month by month mean to average irregularity.

    For example, a June/July/Aug etc. average over the last 10 years of data. This will replicate a grand seasonality index.

    I have tried a few things with egen by year, alas my skills lack in this area.

    Many thanks,
    J

  • #2
    I think you will need to use the "rolling" command, see for example http://www.stata.com/statalist/archi.../msg01478.html, at least to calculate the 10 year average per month. I have no experience with the command myself so I can't really help you much more than that ... (someone else might later on though)

    Comment


    • #3
      There is no information here about precise data structure or variable names, let alone exactly what code you tried or a data example.

      Please do read and act on http://www.statalist.org/forums/help

      This might help with means for months across years.

      Code:
      webuse air2
      gen mdate = ym(1948, 12) + _n
      format mdate %tm
      gen month = month(dofm(mdate))
      tab month
      egen mmean  = mean(air), by(month)
      Graphs for exploring seasonality were discussed in

      SJ-9-2 gr0037 . . . . . . . . Stata tip 76: Separating seasonal time series
      . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . N. J. Cox
      Q2/09 SJ 9(2):321--326 (no commands)
      tip on separating seasonal time series

      SJ-6-3 gr0025 . . . . . . . . . . . . Speaking Stata: Graphs for all seasons
      (help cycleplot, sliceplot if installed) . . . . . . . . . N. J. Cox
      Q3/06 SJ 6(3):397--419
      illustrates producing graphs showing time-series seasonality

      I don't think moving averages are especially useful here. Rather, build seasonality into your model by using an appropriate time series model, or a regression-type model with monthly indicator variables, or something similar.

      Comment

      Working...
      X