2
$\begingroup$

I'm working through this tutorial and this guy run SARIMAX model for a time series with both seasonal and trend components:

# create SARIMAX model with previously determined lags
# sar_m = sarimax.SARIMAX(ts15_train.values,
                    trend='n', 
                    order=(2,1,1), 
                    seasonal_order=(2, 1, 1, 24), 
                    simple_differencing=False).fit()

It seems wrong to me. Am I right here? I read some tutorials here and there and I believe we should eliminate both seasonal and trend components first to make a time series stationary (by performing some transforming operations like ts = log(ts) etc), then predict (e.g. by ARIMA model the next K values) and then bring back our seasonal and trend components (e.g. add a running mean, pow(2, x)).

$\endgroup$
0

3 Answers 3

3
$\begingroup$

No, what you are suggesting is almost entirely incorrect.

For forecasting, "eliminating" trend and seasonal components in the training period puts you in the awkward position of "bringing back" the trend and seasonal components in the forecast period. If your model doesn't detrend/seasonally adjust by defining dynamics for those components (which is the case with many such methods), you have no forecast available for those components; you have to make some kind of ad hoc decision as to what it should be (e.g. copy the last year's seasonal component), or fit another, separate model to those components.

Seasonal ARIMA models explicitly include a type of stochastic trend (if the differencing order is at least 1) and seasonality, which means that they are perfectly capable of accounting for those, including in the forecast period, and there is no reason to remove them first. In particular, ARIMA models are not assumed to be stationary (they are assumed to have a particular type of non-stationarity, though, so for example will not handle error variance that increases with the level).

At the end of your post, you seem to be suggesting having a deterministic trend ("pow(2,x)"?), which should also be done jointly with estimating the ARIMA model (an ARIMAX or regression with ARIMA errors model), not as a separate step. This is because the parts of a model are rarely independent: your estimate of the trend parameters depends on your estimate for the ARIMA parameters.

$\endgroup$
2
$\begingroup$

Differencing is used to make a time series stationary when applying an $ARIMA(p,d,q)$ model.

The order of differencing is indicated by the number $d$ from the orders $(p,d,q)$ of the model.

For a seasonal model $ARIMA(p,d,q)(P,D,Q)_m$, there will be an additional seasonal differencing order $D$ for the seasonal component.

In your code $d$ and $D$ are already indicated:

sar_m = sarimax.SARIMAX(ts15_train.values,
                trend='n', 
                order=(2,1,1), 
                seasonal_order=(2, 1, 1, 24), 
                simple_differencing=False).fit()

The model being described here is a seasonal $ARIMA(2,1,1)(2,1,1)_{24}$ so you $d=1$ and your $D=1$ and you don't need to do anything, your code is doing the required transformation already.

$\endgroup$
0
$\begingroup$

Identification of a transfer function is described here https://web.archive.org/web/20160216193539/https://onlinecourses.science.psu.edu/stat510/node/75/ and Transfer function in forecasting models - interpretation and Determining odd time series (follow @javlacelle) . I would just let an automatic transfer function program determine the appropriate differencing (pre-whitening structure) for all stochastic input series in the model.

As an aside on your reference . prophet (among other things !)does not identify lead and lag effects around holidays , level / trend shifts or pulses and assumes that day-of-the-week factors are constant over time thus leading to some poor projections for low-count days. enter image description here

Facebook's strategy is to let the user community debug their package and to suggest improvements.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.