2
$\begingroup$

For data at a weekly level, I'm giving frequency as 52 for the auto.arima function. What happens when a year has 53 weeks? How does it affect the forecast?

$\endgroup$
  • 1
    $\begingroup$ Leap years don't have 53 weeks. Nor do ordinary years have 52. Ordinary years have 52 weeks and one day while leap years have 52 weeks and two days. So if it does anything to deal with the fact that a year isn't a whole number of weeks, it has to do it for every year. $\endgroup$ – Glen_b Jan 15 '15 at 7:33
  • $\begingroup$ Thanks guys. It doesn't matter if Leap years actually have 53 weeks or not. But the data that I have has 52 weeks for an ordinary year and 53 for a leap year. I am just trying to understand how it might affect my forecast if I have 53 weeks of data somewhere in the dataset for a year and the frequency given is 52. Does it affect the seasonality in anyway? $\endgroup$ – Anonymous Jan 15 '15 at 7:53
3
$\begingroup$

You need to create a variable to account for the leap year effect.

For example, a common specificacion with monthly data is to define a column vector with zeros for all months except February. In February, the variable takes on the value 0.75 if it belongs to a leap year and -0.25 otherwise. In this way the leap year effect cancels out over a period of four years and does not affect the mean over this interval.

For weekly data, you could collapse weeks 52 and 53 into a single week (e.g. adding up the values for weeks 52 and 53 of leap years) and then define a dummy that could account for the different number of days in the last week of the year. Following the same idea as above, you could define a dummy with zeros for all weeks of the year except for the last one, which can be set to 0.75 if it belongs to a leap year and -0.25 otherwise.

There may be several other possible specifications for this variable. Regardless of whether it is a leap year or not, the last week of the year does not always have the same number of days. A dummy based on the number of days in the last week may be better, as it may capture the potential effect of the length of the last week both in leap and non-leap years.

Once the dummy has been chosen and built, it can be passed to stats::arima and forecast::auto.arima through the argument xreg. When forecasting, remember that you need to extend this dummy for the out-of-sample periods.

$\endgroup$
1
$\begingroup$

Unfortunately, auto.arima does not seem to pay any attention to leap years. Thus if your data spans more than a few years, the 52-week frequency starts being a problem. You are getting out of sync at a pace of approximately one week every 5-6 years.

As regards seasonality, the first time "week 53" is encountered in your data, it will be treated as week 1 (because your specified frequency is 52), then the subsequent "week 1" will be treated as week 2 etc. The discrepancy will persist and even grow with every new "week 53".

Here is a useful treatment of weekly data by the author of the forecast package and the auto.arima function. It might help you solve the underlying problem.

$\endgroup$

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.