Search code examples
pythonarimasarimax

AutoArima - Selecting correct value for m


So for argument sake here is an example of autoarima for daily data:

auto_arima(df['orders'],seasonal=True,m=7)

Now in that example after running a Seasonal Decomposition that has shown weekly seasonality I "think" you select 7 for m? Is this correct as the seasonality is shown to be weekly?

My first question is as follows - If seasonality is Monthly do you use 12? If it is Annually do you use 1? And is there ever a reason to select 365 for daily?

Secondly if the data you are given is already weekly e.g

date         weekly tot
2021/01/01 - 10,000
2021/01/07 - 15,000
2021/01/14 - 9,000
and so on......

And you do the seasonal decomposition would m=1 be used for weekly, m=4 for monthly and m=52 for annually.

Finally if its monthly like so:

date        monthly tot
2020/01/01- 10,000
2020/02/01- 15,000
2020/03/01- 9,000
and so on......

And you do the seasonal decomposition would m=1 for monthly and m=12 for annually.

Any help would be greatly appreciated, I just want to be able to confidently select the right criteria.


Solution

  • A season is a recurring pattern in your data and m is the length of that season. m in that case is not a code or anything but simply the length:

    Imagine the weather, if you had the weekly average temperature it will rise in the summer and fall in the winter. Since the length of one "season" is a year or 52 weeks, you set m to 52. If you had a repeating pattern every quarter, then m would be 12, since a quarter is equal to 12 weeks. It always depends on your data and your use case.

    To your questions:

    If seasonality is Monthly do you use 12?

    If the pattern you are looking for repeats every 12 months yes, if it repeats every 3 months it would be 3 and so on.

    If it is Annually do you use 1?

    A seasonality of 1 does not really make sense, since it would mean that you have a repeating pattern in every single data point.

    And is there ever a reason to select 365 for daily?

    If your data is daily and the pattern repeats every 365 days (meaning every year) then yes (you need to remember that every fourth year has 366 days though).

    I hope you get the concept behind seasonality and m so you can answer the rest.