Free tools Windows power users keep installed
One-click scans. No signup required.
SARIMA is seasonal ARIMA: a forecasting model that combines ordinary autoregressive, differencing, and moving-average terms with their seasonal counterparts. It is written as (p,d,q) × (P,D,Q,s). In Python’s statsmodels library, specify those two groups with order and seasonal_order; validate candidate models against future, held-out observations rather than choosing an order by appearance alone.
What is SARIMA?
SARIMA stands for Seasonal AutoRegressive Integrated Moving Average. It extends ARIMA to represent repeating patterns, such as monthly observations that tend to follow an annual cycle. The statsmodels ARIMA API reference describes its ARIMA interface as covering models with seasonal components and exogenous regressors, and gives the general seasonal form as (p,d,q) × (P,D,Q,s).
The first triplet describes non-seasonal behavior; the second describes seasonal behavior. In statsmodels, order=(p,d,q) and seasonal_order=(P,D,Q,s) are the corresponding arguments.
What p, d, and q mean
- p is the non-seasonal autoregressive order: how many recent lagged values contribute to the model.
- d is the number of ordinary differences applied to help remove a stochastic trend and achieve stationarity.
- q is the non-seasonal moving-average order: how many recent forecast errors contribute to the model.
What P, D, Q, and s mean
- P is the seasonal autoregressive order.
- D is the seasonal differencing order.
- Q is the seasonal moving-average order.
- s is the number of observations in one seasonal cycle. For example, statsmodels identifies 12 as a common period for monthly data and 4 for quarterly data.
These orders are not a recipe for automatically removing every visible pattern. A calendar cycle helps define s, but it does not, by itself, establish that D=1 is appropriate.
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →#1 Best Overall
How do I choose p, d, q and P, D, Q, s?
Start with the sampling interval and the real-world cycle, then test a small number of plausible specifications. There is no universally best order: the choice depends on the series and should be judged with time-ordered validation.
- Prepare the time index. Parse timestamps, sort observations chronologically, set a regular frequency where appropriate, and identify missing observations.
- Plot the series. Look for trend, changing variance, outliers, and recurring cycles before choosing model terms.
- Choose
sfrom frequency and domain knowledge. Monthly observations with annual seasonality often uses=12; quarterly observations with annual seasonality often uses=4. - Difference sparingly. Consider ordinary differencing
dfor a non-seasonal trend and seasonal differencingDfor repeating seasonal level shifts. Too much differencing can introduce unnecessary dependence and make forecasts unstable. - Begin with a small candidate set. Keep
p,q,P, andQlow at first. Include a seasonal-naive baseline and a simpler non-seasonal model so the seasonal specification has something meaningful to beat. - Keep validation in the future. Fit each candidate only to its training window, then assess it on later observations. Rolling-origin or blocked time validation preserves the direction of forecasting; random shuffling does not.
- Compare more than fit scores. AIC and BIC are useful for comparing candidate models, but they do not replace out-of-sample forecast error. Also inspect residuals, parameter uncertainty, and prediction intervals.
Residual autocorrelation, remaining seasonality, non-constant variance, or large outliers are signs to review the specification. A good in-sample information criterion alone does not show that a model forecasts well or has well-calibrated intervals.
Rank #2
How do I fit SARIMA in Python with statsmodels?
For a seasonal model without external predictors, statsmodels’ SARIMAX state-space class is a direct implementation path. Replace the example orders and horizon with choices appropriate to the data:
from statsmodels.tsa.statespace.sarimax import SARIMAX
model = SARIMAX(
y_train,
order=(p, d, q),
seasonal_order=(P, D, Q, s),
)
result = model.fit()
print(result.summary())
forecast = result.get_forecast(steps=horizon)
mean_forecast = forecast.predicted_mean
intervals = forecast.conf_int()
The statsmodels state-space guide demonstrates fitting with order=(1,1,1) and seasonal_order=(0,1,1,4). The fitted results object provides standard errors and z-statistics as well as prediction and forecasting methods. These diagnostics help assess the estimated model; they do not establish that its forecast will be accurate on new data.
Rank #3
The ARIMA API also documents choices including trend, enforce_stationarity, and enforce_invertibility. Treat these as specification and constraint choices, not switches to change blindly to improve a result.
What does seasonal_order mean in statsmodels?
seasonal_order is a four-item tuple in this exact order: (P,D,Q,s). It specifies seasonal autoregressive order, seasonal differencing, seasonal moving-average order, and the number of observations in a seasonal period. For example, seasonal_order=(0,1,1,4) uses one seasonal difference and one seasonal moving-average term for a four-observation cycle; it does not mean four seasonal differences.
The period depends on the data’s sampling frequency and the cycle being modeled. A period of 12 can represent a yearly cycle in monthly data, while 4 commonly represents a yearly cycle in quarterly data. If the data frequency is irregular or the cycle is not aligned with the observation interval, choosing a period requires additional care rather than copying one of these examples.
SARIMA versus SARIMAX: when should I use exogenous variables?
SARIMA describes the seasonal ARIMA structure when the model uses the series’ own history. In statsmodels, SARIMAX is the flexible state-space class; its exog argument allows external regressors alongside the seasonal structure. The official SARIMAX API reference documents the seasonal order as (P,D,Q,s).
Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minutePC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Best Value
External predictors are useful only when they are available in the forecasting setup. To forecast with exog, supply future predictor values for the forecast horizon, or forecast those predictors separately. If future values are unknown, the forecast depends on assumptions or additional forecasts for them; adding regressors does not remove that dependency.
How do I forecast with SARIMAX and prediction intervals?
After fitting on the training observations, request forecasts for the intended horizon. The interval bounds below come from the fitted result; state the horizon and interval level when communicating them, and remember they are conditional on the model specification and any supplied future regressors.
horizon = 8
forecast = result.get_forecast(steps=horizon)
mean_forecast = forecast.predicted_mean
intervals = forecast.conf_int(alpha=0.05)
When the model includes regressors, pass an exog array containing the predictor values for those same future steps to get_forecast. The example’s alpha=0.05 requests a 95% interval under the model’s interval convention; it is not a guarantee that the interval will contain future observations 95% of the time. Check interval behavior on held-out data if calibrated uncertainty matters.
How should I validate and refit a SARIMA forecast?
Use a time-ordered holdout or rolling-origin evaluation that reflects how the forecast will actually be made. Compare forecast errors against a seasonal-naive baseline and simpler alternatives at the same horizon. Examine whether errors are systematically biased or remain seasonal, and check whether observed holdout values are reasonably represented by the prediction intervals.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
After selecting a specification based on that validation, refit it on all historical observations only when the validation design supports that decision. Preserve the chosen forecast horizon and document assumptions about future exogenous values so the forecast can be interpreted and reproduced.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

