https://github.com/nixtla logo
#statsforecast
Title
# statsforecast
m

Matej

08/13/2023, 7:51 AM
Hi all, the Original MSTL paper suggest the following set up for trend estimation
Copy code
Next, the trend component of the time series is computed using the last iteration of STL. On the other hand, if the time series is non-seasonal, MSTL uses the Friedman's Super Smoother function, supsmu, available in R (R Core Team, 2020), to directly estimate the trend.
In Nixtla it seems AutoArima is used and I wonder if this is the preferred set up, or perhaps can I set up the original MSTL as presented in the paper somehow? Without the AutoARIMA?
k

Kevin Kho

08/13/2023, 11:41 PM
I looked it up, and the Super Smoother function is not available in Nixtla, but you can try it with other models. The closest might be SimpleSmooth, so you can do:
Copy code
models = [MSTL(
    season_length=[24, 24 * 7], # seasonalities of the time series 
    trend_forecaster=SimpleExponentialSmoothing() # model used to forecast trend
)]

forecasts = sf.predict(h=24, level=[90])
forecasts.head()
You also might be able to create your own
StatsForecast
compatible model with an existing supersmoother implementation. For example:
Copy code
from statsforecast.models import _TS
from supersmoother import SuperSmoother

class _SuperSmoother(_TS):
    def __init__():
        self.model = SuperSmoother()
   
    def fit(self, t, y, dy):
        self.model.fit(t, y, dy)

    def predict(self, tfit):
        self.model.predict(tfit)
The Naive model might provide guidance. I’m not sure this will work. You need to shape the output a bit, like
predict
outputs a dictionary, which
StatsForecast
turns into a DataFrame later. The easiest thing to do is probably approximate it with the SimpleExponentialSmoothing, which is also meant for timeseries without seasonability