error in stl, series has less than two periods (erroneous?)

雨燕双飞 提交于 2019-12-06 08:41:41

It holds true for all kind of periodic series, be it a weekly or yearly or any other period. You have to have atleast 1 extra data point, in addition to atleast 2 complete cycles of the period.

Here is an example for weekly series where you will get error too:

dat_Weekly <- cumsum(rnorm(104,0,5))
x_Weekly <- ts(dat_Weekly, frequency = 52, start = c(2013))
stl(x_Weekly, "periodic")

You can go through the original paper: here

Below explanation might not be the best one, but I want to give a shot.

Let's say you have exactly 2 years of monthly sales data (24 data points) for an ice-cream company and your goal is to find out seasonality in it.

First thing STL would do is consume the data for 2 or more years (24 or 36 or 48 months) in order to calculate Seasonality, Trend etc. In this case we have exactly 24 data points. Now, STL would required atleast an additional data point ON which it would predict the seasonality. Since STL has already used your first 24 data points in learning the monthly seasonality, the next data point is absolutely required to extend what has been predicted earlier.

In other words, first 24 data points are being used to check out the seasonality while the next data points (greater than 24) will follow the previously calculated seasonal patterns of two years. For January sales, you might see a dip in the STL plot.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!