Announcement

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

  • Linearly weighted moving averages

    I may have been blanking this out for some time, but I've only very recently stumbled on linearly weighted moving averages

    https://numerical.recipes/whp/notes/movingaverages.pdf

    and on a Google found that this is utterly standard in at least one field

    https://www.investopedia.com/terms/l...ingaverage.asp

    -- so that this may well be banal to many readers. If anyone knows early references or ideally the original reference, that would be very interesting, although as so often multiple re-inventions seem likely.

    To the point: this is a moving average of the present value and some previous values so that weights vary linearly with a maximum weight for the present value.

    So, it's a simpler analogue of exponentially weighted moving averages, which have been a thing for several decades.

    It's pleasant to report that this is already quite easy with tssmooth, so that e.g. for a window of length 12


    Code:
    . use https://www.stata-press.com/data/r18/wpi1.dta, clear
    
    . tssmooth ma whatever=ln_wpi, weight(1/11 <12>)
    shows how to get

    (1 * x[t-11] + 2 * x[t-10] + ... + 11 * x[t-1] + 12 * x[t - 0]) / (1 + 2 + ... + 11 + 12)

Working...
X