Announcement

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

  • Demeaning data on a rolling window

    Hello Statalists,

    I need to dynamically demean a time series by the following backward looking rolling window of forty quarters:

    Click image for larger version

Name:	rolling window.jpg
Views:	2
Size:	3.9 KB
ID:	1710610


    That is, I need to replace each observation with the observation itself minus the mean computed in a rolling window of 10 years.

    Can you help me please?

    Giacomo

  • #2
    tssmooth ma might work.

    Comment


    • #3
      Code:
      clear
      set obs 30
      g N = _n
      tsset N
      tssmooth ma maN = N , window(10)
      replace maN = . if N<10

      Comment

      Working...
      X