SARIMAXModel¶
- class SARIMAXModel(order: Tuple[int, int, int] = (2, 1, 0), seasonal_order: Tuple[int, int, int, int] = (1, 1, 0, 12), trend: Optional[str] = 'c', measurement_error: bool = False, time_varying_regression: bool = False, mle_regression: bool = True, simple_differencing: bool = False, enforce_stationarity: bool = True, enforce_invertibility: bool = True, hamilton_representation: bool = False, concentrate_scale: bool = False, trend_offset: float = 1, use_exact_diffuse: bool = False, dates: Optional[List[datetime.datetime]] = None, freq: Optional[str] = None, missing: str = 'none', validate_specification: bool = True, **kwargs)[source]¶
Bases:
etna.models.base.PerSegmentPredictionIntervalModel
Class for holding Sarimax model.
Notes
We use
statsmodels.tsa.sarimax.SARIMAX
. Statsmodels package uses exog attribute for exogenous regressors which should be known in future, however we use exogenous for additional features what is not known in future, and regressors for features we do know in future.Init SARIMAX model with given params.
- Parameters
order (Tuple[int, int, int]) – The (p,d,q) order of the model for the number of AR parameters, differences, and MA parameters. d must be an integer indicating the integration order of the process, while p and q may either be an integers indicating the AR and MA orders (so that all lags up to those orders are included) or else iterables giving specific AR and / or MA lags to include. Default is an AR(1) model: (1,0,0).
seasonal_order (Tuple[int, int, int, int]) – The (P,D,Q,s) order of the seasonal component of the model for the AR parameters, differences, MA parameters, and periodicity. D must be an integer indicating the integration order of the process, while P and Q may either be an integers indicating the AR and MA orders (so that all lags up to those orders are included) or else iterables giving specific AR and / or MA lags to include. s is an integer giving the periodicity (number of periods in season), often it is 4 for quarterly data or 12 for monthly data. Default is no seasonal effect.
trend (Optional[str]) – Parameter controlling the deterministic trend polynomial \(A(t)\). Can be specified as a string where ‘c’ indicates a constant (i.e. a degree zero component of the trend polynomial), ‘t’ indicates a linear trend with time, and ‘ct’ is both. Can also be specified as an iterable defining the non-zero polynomial exponents to include, in increasing order. For example, [1,1,0,1] denotes \(a + bt + ct^3\). Default is to not include a trend component.
measurement_error (bool) – Whether or not to assume the endogenous observations endog were measured with error. Default is False.
time_varying_regression (bool) – Used when an explanatory variables, exog, are provided provided to select whether or not coefficients on the exogenous regressors are allowed to vary over time. Default is False.
mle_regression (bool) – Whether or not to use estimate the regression coefficients for the exogenous variables as part of maximum likelihood estimation or through the Kalman filter (i.e. recursive least squares). If time_varying_regression is True, this must be set to False. Default is True.
simple_differencing (bool) – Whether or not to use partially conditional maximum likelihood estimation. If True, differencing is performed prior to estimation, which discards the first \(s D + d\) initial rows but results in a smaller state-space formulation. See the Notes section for important details about interpreting results when this option is used. If False, the full SARIMAX model is put in state-space form so that all datapoints can be used in estimation. Default is False.
enforce_stationarity (bool) – Whether or not to transform the AR parameters to enforce stationarity in the autoregressive component of the model. Default is True.
enforce_invertibility (bool) – Whether or not to transform the MA parameters to enforce invertibility in the moving average component of the model. Default is True.
hamilton_representation (bool) – Whether or not to use the Hamilton representation of an ARMA process (if True) or the Harvey representation (if False). Default is False.
concentrate_scale (bool) – Whether or not to concentrate the scale (variance of the error term) out of the likelihood. This reduces the number of parameters estimated by maximum likelihood by one, but standard errors will then not be available for the scale parameter.
trend_offset (float) – The offset at which to start time trend values. Default is 1, so that if trend=’t’ the trend is equal to 1, 2, …, nobs. Typically is only set when the model created by extending a previous dataset.
use_exact_diffuse (bool) – Whether or not to use exact diffuse initialization for non-stationary states. Default is False (in which case approximate diffuse initialization is used).
dates (Optional[List[datetime.datetime]]) – If no index is given by endog or exog, an array-like object of datetime objects can be provided.
freq (Optional[str]) – If no index is given by endog or exog, the frequency of the time-series may be specified here as a Pandas offset or offset string.
missing (str) – Available options are ‘none’, ‘drop’, and ‘raise’. If ‘none’, no nan checking is done. If ‘drop’, any observations with nans are dropped. If ‘raise’, an error is raised. Default is ‘none’.
validate_specification (bool) – If True, validation of hyperparameters is performed.
- Inherited-members
Methods
fit
(ts)Fit model.
forecast
(ts[, prediction_interval, quantiles])Make predictions.
get_model
()Get internal models that are used inside etna class.