3
$\begingroup$

I originally posted this on Stack Overflow, and it was suggested that this question would be better suited for CV:

With reference to the HoltWinters function in R, how does one deal with time periods with irregular frequencies (f)?

Most obviously, there is an irregular number of days in the year - 365 or 366, depending on whether it's a leap year or not, and an irregular number of weeks, which, depending on the week numbering system used, may be of differing lengths.

In Excel, I deal with this by simply changing the formulae in each cell to refer to the "correct" date from the previous year for seasonality purposes. With R, I can't see any way of doing this using the pre-made HoltWinters algorithm, since it requires you to specify a fixed frequency (f).

I suppose I could create a different, bespoke, HW algorithm, and then use the "optim" section to identify the correct parameters, but I don't know how efficient/time consuming this would be.

How does one deal with this problem?

$\endgroup$
1
$\begingroup$

I don't know about the specific case for daily 365/366 time series, but this is similar to the 52 week vs 53 week issue for some yearly time series.

In the case of 52 vs. 53 weeks, the algorithm (whether Holt-Winters or another forecasting algorithm) can't handle it, you need to preprocess the data to transform the 53 week data into 52 weeks using a suitable mapping and then just apply the algorithm to that data.

Something similar can be done for 365 days vs. 366 days.

$\endgroup$
  • $\begingroup$ Thanks for the answer. So having scanned the link you posted, it seems as though one solution is just to omit awkward weeks, so that one only considers 52 full weeks (and ignores days which don't fit into this timeframe). The alternative is presumably to create weeks/days of weird lengths - e.g. convert each week to be 1.019 of an actual week - although this would only work if the modular of days/52 is always consistent. Don't see how this could work for leap years, though, since the actual length of the years in days differs across years. $\endgroup$ – Statsanalyst Jan 2 '18 at 17:33
  • $\begingroup$ Given how frequent a problem I imagine this must be, I imagine there must be some kind of solution? $\endgroup$ – Statsanalyst Jan 2 '18 at 17:33
  • $\begingroup$ @Statsanalyst in my particular area of interest, which is retail demand forecasting, depending on the year, we either just delete the additional week, or we calculate the average of the first two weeks or last two weeks of the series, under the assumption that they are similar. When adjusting the number of weeks we also try to pay attention to which week specific events like Christmas or the super bowl occur and how they would shift based on our transformation. I don't know how this would be applied in the 365/366 case, but I hope it helps. $\endgroup$ – Skander H. Jan 2 '18 at 20:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.