Tuesday, June 04, 2019

How About This for Calculating the 1-year Moving Average?

Update 6/10: A commenter got me thinking about this more, and I'm convinced now that there is no problem using the 365-day moving average for the 1-year moving average. See the comments for more explanation. Thanks Victor!

So I've been thinking more about how to calculate the 1-year moving average (MA) of daily data, which is complicated by leap years, which over several decades can leave you astray by several days, which affects the value of the 1-yr MA. (About 10 days over 4 decades, a third of a month.)

Any opinions on this proposal?

To me this seems the least arbitrary of anything I've seen so far. Thoughts?


Victor Venema said...

What do you mean with getting problems when you compute this over many decades? Also at the end of several decades the moving average would be the one over the last 365 or 366 days.

The equation looks needlessly complicated, but is fine. The difference between using the last 365 or the last 366 days will be so small that I would simply pick one.

David Appell said...

Victor, I need to think about this some more. I'll get back to you.

David Appell said...

Victor, I think I've managed to convince myself that you're right, and there isn't a problem using the 356-day moving average for the 1-year moving average.

Usually the 365-day MA would be

1/2/2018 to 1/1/2019
1/3/2018 to 1/2/2019
1/4/2018 to 1/3/2019...

in (sorry) US notation mm/dd/yy. That goes fine until you get to a leap year, when after Feb 29 you get

2/28/2019 to 2/27/2020
3/1/2019 to 2/28/2020
3/2/2019 to 2/29/2020
3/3/2019 to 3/1/2020
3/4/2019 to 3/2/2020
3/5/2019 to 3/3/2020
3/6/2019 to 3/4/2020...

which looks like an off-by-one error. And it stays like that for 365 days, BUT the next year it reverts back to

3/1/2020 to 2/28/2021
3/2/2020 to 3/1/2021
3/3/2020 to 3/2/2021
3/4/2020 to 3/3/2021...

and onward to

12/31/2020 to 12/30/2021
1/1/2020 to 12/31/2021
1/2/2021 to 1/1/2022
1/3/2021 to 1/2/2022...

which (compare to the first group of dates) is back to normal.

So I think you're right, and there is no problem using the 365-day MA as the 1-yr MA.

David Appell said...

PS: Thanks for getting me to question what I was thinking.