Which is better, stl or decompose? I am doing time series analysis using R. I have to decompose my data into trend, seasonal and random component. I have weekly data for 3 years. I have found two functions in R -- stl() and decompose(). I have read that stl() is not good for multiplicative decomposition. Can anybody tell me in what scenario these functions can be used?
 A: I would say STL. STL does trend and seasonal see: http://www.wessa.net/download/stl.pdf
Decompose only does seasonal see the documentation here: http://stat.ethz.ch/R-manual/R-devel/library/stats/html/decompose.html
When you work with them be sure to include your trend type (multiplicative, additive) and season type (multiplicative, additive). Trends can also sometimes have a damping factor too.
By multiplicative decomposition I assume you mean in the case for trend. You are not likely to use multiplicative decomposition unless you are decomposing a exponential growth function.
A: Disadvantages of decompose function in R:


*

*The estimate of the trend is unavailable for the first few and last few observations.

*It assumes that the seasonal component repeats from year to year.


So I would prefer STL. It is possible to obtain a multiplicative decomposition by first taking logs of the data and then back-transforming the components.
A: STL is a more advanced technique to extract seasonality, in the sense that is allows seasonality to vary, which is not the case in decompose.
To get an understanding at how STL works:


*

*the algorithm estimates every seasonal sub-serie (in a 7-day seasonality, it will estimate 7 sub-series: the Monday time serie, the Tuesday time serie, etc.),

*it will then estimate the local seasonality by running a loess regression on every sub-serie.


This allows to capture the varying effect in the seasonality. If you do not want your seasonality to vary (in other words the estimated effect of each sub-serie will remain constant across the whole time serie), you can specify the seasonal window to be infinite or "periodic". This is equivalent to average each sub-serie and giving an equal weight to all points (you do not have any "local" effect anymore). decompose is essentially the same, as the seasonal sub-components will remain constant across your whole time serie, which is a special configuration of STL.
This is pretty well explained here: https://www.otexts.org/fpp/6/1.
STL estimates seasonality in an additive way. As explained a few pages later in the previous source, you can estimate seasonality in a multiplicative way by resorting to log transformation (or Cox-Box transformation).
