Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Statsmodels seasonal_decompose - what is naive about it?

Have been working with time series in Python, and using sm.tsa.seasonal_decompose. In the docs they introduce the function like this:

We added a naive seasonal decomposition tool in the same vein as R’s decompose.

Here is a copy of the code from the docs and its output:

import statsmodels.api as sm

dta = sm.datasets.co2.load_pandas().data
# deal with missing values. see issue
dta.co2.interpolate(inplace=True)

res = sm.tsa.seasonal_decompose(dta.co2)
res.plot()

seasonal decomposition plot

They say it is naive but there is no disclaimer about what is wrong with it. Does anyone know?

like image 377
cardamom Avatar asked Nov 02 '17 13:11

cardamom


1 Answers

I made some (aehm...naive) researches, and, according to the reference, it seems that StatsModels uses the classic moving average method to detect trends and apply seasonal decomposition (you can check more here, specifically about Moving Average and Classical Decomposition).

However, other advanced seasonal decomposition techniques are available, such as STL decomposition, which also has some Python implementations. (UPDATE - 11/04/2019 as pointed out in the comments by @squarespiral, such implementations appear to have been merged in the master branch of StatsModels).

At the above links, you can find a complete reference on the advantages and disadvantages of each one of the proposed methods.

Hope it helps!

like image 149
Angelo Cardellicchio Avatar answered Nov 06 '22 05:11

Angelo Cardellicchio