# tbats with weekly, monthly and yearly seasonality not working

I am trying to predict values based on a dataset which may contain weekly, monthly and yearly seasonal data. To simplify things I am assuming that all months have four weeks (28 days) and the year has twelve months (336 days).

I am using the following code in R:

forecast(tbats(data,seasonal.periods=c(7,28,336)))


this does not pick up the yearly seasonality. What am I doing wrong? Interestingly the following line delivers different results:

forecast(tbats(msts(b,seasonal.periods=c(7,28,336))))


Whats the reason?

The dataset:

c(1,1,1,1,1,7,7,1,1,1,1,1,7,7,1,1,1,1,1,14,14,1,1,1,1,1,7,7,29,29,29,29,29,29,29,1,1,1,1,1,7,7,1,1,1,1,1,14,14,1,1,1,1,1,7,7,1,1,1,1,1,7,7,1,1,1,1,1,7,7,1,1,1,1,1,14,14,1,1,1,1,1,7,7,1,1,1,1,1,7,7,1,1,1,1,1,7,7,1,1,1,1,1,14,14,1,1,1,1,1,7,7,1,1,1,1,1,7,7,1,1,1,1,1,7,7,1,1,1,1,1,14,14,1,1,1,1,1,7,7,1,1,1,1,1,7,7,1,1,1,1,1,7,7,1,1,1,1,1,14,14,1,1,1,1,1,7,7,1,1,1,1,1,7,7,1,1,1,1,1,7,7,1,1,1,1,1,14,14,1,1,1,1,1,7,7,1,1,1,1,1,7,7,1,1,1,1,1,7,7,1,1,1,1,1,14,14,1,1,1,1,1,7,7,1,1,1,1,1,7,7,1,1,1,1,1,7,7,1,1,1,1,1,14,14,1,1,1,1,1,7,7,1,1,1,1,1,7,7,1,1,1,1,1,7,7,1,1,1,1,1,14,14,1,1,1,1,1,7,7,1,1,1,1,1,7,7,1,1,1,1,1,7,7,1,1,1,1,1,14,14,1,1,1,1,1,7,7,1,1,1,1,1,7,7,1,1,1,1,1,7,7,1,1,1,1,1,14,14,1,1,1,1,1,7,7,1,1,1,1,1,7,7,1,1,1,1,1,7,7,1,1,1,1,1,14,14,1,1,1,1,1,7,7,29,29,29,29,29,29,29,1,1,1,1,1,7,7,1,1,1,1,1,14,14,1,1,1,1,1,7,7,1,1,1,1,1,7,7,1,1,1,1,1,7,7,1,1,1,1,1,14,14,1,1,1,1,1,7,7,1,1,1,1,1,7,7,1,1,1,1,1,7,7,1,1,1,1,1,14,14,1,1,1,1,1,7,7,1,1,1,1,1,7,7,1,1,1,1,1,7,7,1,1,1,1,1,14,14,1,1,1,1,1,7,7,1,1,1,1,1,7,7,1,1,1,1,1,7,7,1,1,1,1,1,14,14,1,1,1,1,1,7,7,1,1,1,1,1,7,7,1,1,1,1,1,7,7,1,1,1,1,1,14,14,1,1,1,1,1,7,7,1,1,1,1,1,7,7,1,1,1,1,1,7,7,1,1,1,1,1,14,14,1,1,1,1,1,7,7,1,1,1,1,1,7,7,1,1,1,1,1,7,7,1,1,1,1,1,14,14,1,1,1,1,1,7,7,1,1,1,1,1,7,7,1,1,1,1,1,7,7,1,1,1,1,1,14,14,1,1,1,1,1,7,7,1,1,1,1,1,7,7,1,1,1,1,1,7,7,1,1,1,1,1,14,14,1,1,1,1,1,7,7,1,1,1,1,1,7,7,1,1,1,1,1,7,7,1,1,1,1,1,14,14,1,1,1,1,1,7,7)


Thanks a lot!

Update:

As suggested in the comments I updated the dataset to use 13 quad weeks or a real year with 365 days (posted for 365 days):

c(1,1,1,1,1,7,7,1,1,1,1,1,7,7,1,1,1,1,1,14,14,1,1,1,1,1,7,7,29,29,29,29,29,29,29,1,1,1,1,1,7,7,1,1,1,1,1,7,7,1,1,1,1,1,14,14,1,1,1,1,1,7,7,1,1,1,1,1,7,7,1,1,1,1,1,7,7,1,1,1,1,1,14,14,1,1,1,1,1,7,7,1,1,1,1,1,7,7,1,1,1,1,1,7,7,1,1,1,1,1,14,14,1,1,1,1,1,7,7,1,1,1,1,1,7,7,1,1,1,1,1,7,7,1,1,1,1,1,14,14,1,1,1,1,1,7,7,1,1,1,1,1,7,7,1,1,1,1,1,7,7,1,1,1,1,1,14,14,1,1,1,1,1,7,7,1,1,1,1,1,7,7,1,1,1,1,1,7,7,1,1,1,1,1,14,14,1,1,1,1,1,7,7,1,1,1,1,1,7,7,1,1,1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,1,14,14,1,1,1,1,1,7,7)


The algorithm is still not picking up the yearly seasonality and the results for using an msts object and providing the seasonal periods directly in the tbats call are still different.

• Can you give some more information about your dataset + why you assume that all months have 28days and a year 336days? As far as i can see your dataset is less than 2 years in total, right? – RandomDude Oct 20 '15 at 11:38
• This is just an example dataset. It might look different, but in general it should be similar. Any other information that would be interesting? I assume that months have 28 days and a year 336 days because it is easier to not have months with a varying number of days. As far as I understand, it should not make any difference as long as I set the seasonal periods correctly? The dataset has exactly 672 datapoint which is exactly two years of 336 days. Even if I use data for 4 years the yearly seasonality is not picked up. – user2927294 Oct 20 '15 at 16:52
• I can not follow your argumentation of 28 and 336 days at all, especially since tbats and msts-objects allow you to deal with the varying lengths of months and years. Talking about monthly seasonal data: your data has a certain pattern that repeats every month? e.g. beginning of the month always stronger than end of the month. i would suggest you to work with the data as it is - no shrinkage to 28 days - and use and msts-object like this: msts(data, seasonal.periods = c(7, 365.25/12, 365.25)) Maybe you did that already and it did not work out? – RandomDude Oct 20 '15 at 18:38
• A typical way to deal with this issue is to have 13 quadweeks of 28 days. This is 364 days, so you change a day each year (or ignore a day, etc.). Note in this way each quadweek "month" has an equal number of weekend days. – zbicyclist Oct 21 '15 at 3:52
• My argumentation about the 28 days might be unclear. But I thought it should still work if I provide the correct seasonal periods in the msts call. My data does have a certain pattern that repeats every month (if all month have 28 days). Every third weekend in a month has two times higher values than the other weekends. Except for the seconds month of the year. As stated in the update using 365 days and the quad weeks did not work out. – user2927294 Oct 21 '15 at 9:14