StatsModelsARIMA
StatsModelsARIMA
- class StatsModelsARIMA(order: tuple[int, int, int] = (0, 0, 0), seasonal_order: tuple[int, int, int, int] = (0, 0, 0, 0), trend: str | Iterable | None = None, enforce_stationarity: bool = True, enforce_invertibility: bool = True, concentrate_scale: bool = False, trend_offset: int = 1, dates: ndarray | None = None, freq: str | None = None, missing: str | None = None, validate_specification: bool = True, start_params: ndarray | None = None, transformed: bool = True, includes_fixed: bool = False, method: str | None = None, method_kwargs: dict | None = None, gls: bool = False, gls_kwargs: dict | None = None, cov_type: str = 'opg', cov_kwds: dict | None = None, return_params: bool = False, low_memory: bool = False)[source]
(S)ARIMA(X) forecaster, from statsmodels, tsa.arima module.
Direct interface for
statsmodels.tsa.arima.model.ARIMA.Users should note that statsmodels contains two separate implementations of (S)ARIMA(X), the ARIMA and the SARIMAX class, in different modules:
tsa.arima.model.ARIMAandtsa.statespace.SARIMAX.These are implementations of the same underlying model, (S)ARIMA(X), but with different fitting strategies, fitted parameters, and slightly differing behaviour. Users should refer to the statsmodels documentation for further details: https://www.statsmodels.org/dev/examples/notebooks/generated/statespace_sarimax_faq.html
- Parameters:
- ordertuple, optional
The (p,d,q) order of the model for the autoregressive, differences, and moving average components. d is always an integer, while p and q may either be integers or lists of integers.
- seasonal_ordertuple, optional
The (P,D,Q,s) order of the seasonal component of the model for the AR parameters, differences, MA parameters, and periodicity. Default is (0, 0, 0, 0). D and s are always integers, while P and Q may either be integers or lists of positive integers.
- trendstr{‘n’,’c’,’t’,’ct’} or iterable, optional
Parameter controlling the deterministic trend. Can be specified as a string where ‘c’ indicates a constant term, ‘t’ indicates a linear trend in time, and ‘ct’ includes both. Can also be specified as an iterable defining a polynomial, as in
numpy.poly1d, where[1,1,0,1]would denote \(a + bt + ct^3\). Default is ‘c’ for models without integration, and no trend for models with integration. Note that all trend terms are included in the model as exogenous regressors, which differs from how trends are included inSARIMAXmodels. See the Notes section for a precise definition of the treatment of trend terms.- enforce_stationaritybool, optional
Whether or not to require the autoregressive parameters to correspond to a stationarity process.
- enforce_invertibilitybool, optional
Whether or not to require the moving average parameters to correspond to an invertible process.
- concentrate_scalebool, optional
Whether or not to concentrate the scale (variance of the error term) out of the likelihood. This reduces the number of parameters by one. This is only applicable when considering estimation by numerical maximum likelihood.
- trend_offsetint, optional
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.- datesarray_like of datetime, optional
If no index is given by
endogorexog, an array-like object of datetime objects can be provided.- freqstr, optional
If no index is given by
endogorexog, the frequency of the time-series may be specified here as a Pandas offset or offset string.- missingstr
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’.
- start_paramsarray_like, optional
Initial guess of the solution for the loglikelihood maximization. If None, the default is given by Model.start_params.
- transformedbool, optional
Whether or not
start_paramsis already transformed. Default is True.- includes_fixedbool, optional
If parameters were previously fixed with the
fix_paramsmethod, this argument describes whether or notstart_paramsalso includes the fixed parameters, in addition to the free parameters. Default is False.- methodstr, optional
The method used for estimating the parameters of the model. Valid options include ‘statespace’, ‘innovations_mle’, ‘hannan_rissanen’, ‘burg’, ‘innovations’, and ‘yule_walker’. Not all options are available for every specification (for example ‘yule_walker’ can only be used with AR(p) models).
- method_kwargsdict, optional
Arguments to pass to the fit function for the parameter estimator described by the
methodargument.- glsbool, optional
Whether or not to use generalized least squares (GLS) to estimate regression effects. The default is False if
method='statespace'and is True otherwise.- gls_kwargsdict, optional
Arguments to pass to the GLS estimation fit method. Only applicable if GLS estimation is used (see
glsargument for details).- cov_typestr, optional
The
cov_typekeyword governs the method for calculating the covariance matrix of parameter estimates. Can be one of:‘opg’ for the outer product of gradient estimator
‘oim’ for the observed information matrix estimator, calculated using the method of Harvey (1989)
‘approx’ for the observed information matrix estimator, calculated using a numerical approximation of the Hessian matrix.
‘robust’ for an approximate (quasi-maximum likelihood) covariance matrix that may be valid even in the presence of some misspecifications. Intermediate calculations use the ‘oim’ method.
‘robust_approx’ is the same as ‘robust’ except that the intermediate calculations use the ‘approx’ method.
‘none’ for no covariance matrix calculation.
Default is ‘opg’ unless memory conservation is used to avoid computing the loglikelihood values for each observation, in which case the default is ‘oim’.
- cov_kwdsdict or None, optional
A dictionary of arguments affecting covariance matrix computation.
opg, oim, approx, robust, robust_approx
‘approx_complex_step’ : bool, optional - If True, numerical approximations are computed using complex-step methods. If False, numerical approximations are computed using finite difference methods. Default is True.
‘approx_centered’ : bool, optional - If True, numerical approximations computed using finite difference methods use a centered approximation. Default is False.
- return_paramsbool, optional
Whether or not to return only the array of maximizing parameters. Default is False.
- low_memorybool, optional
If set to True, techniques are applied to substantially reduce memory usage. If used, some features of the results object will not be available (including smoothed results and in-sample prediction), although out-of-sample forecasting is possible. Default is False.
- Attributes:
cutoffCut-off = “present time” state of forecaster.
fhForecasting horizon that was passed.
is_fittedWhether
fithas been called.stateState of the estimator.
Examples
>>> from sktime.datasets import load_airline >>> from sktime.forecasting.arima import StatsModelsARIMA >>> y = load_airline() >>> forecaster = StatsModelsARIMA(order=(0, 0, 12)) >>> forecaster.fit(y) >>> y_pred = forecaster.predict(fh=[1,2,3])
Methods
check_is_fitted([method_name])Check if the estimator has been fitted.
clone()Obtain a clone of the object with same hyper-parameters and config.
clone_tags(estimator[, tag_names])Clone tags from another object as dynamic override.
create_test_instance([parameter_set])Construct an instance of the class, using first test parameter set.
create_test_instances_and_names([parameter_set])Create list of all test instances and a list of names for them.
fit(y[, X, fh])Fit forecaster to training data.
fit_predict(y[, X, fh, X_pred])Fit and forecast time series at future horizon.
get_class_tag(tag_name[, tag_value_default])Get class tag value from class, with tag level inheritance from parents.
get_class_tags()Get class tags from class, with tag level inheritance from parent classes.
get_config()Get config flags for self.
get_fitted_params([deep])Get fitted parameters.
get_param_defaults()Get object's parameter defaults.
get_param_names([sort])Get object's parameter names.
get_params([deep])Get a dict of parameters values for this object.
get_pretrained_params([deep])Get pretrained parameters of this estimator.
get_tag(tag_name[, tag_value_default, ...])Get tag value from instance, with tag level inheritance and overrides.
get_tags()Get tags from instance, with tag level inheritance and overrides.
get_test_params([parameter_set])Return testing parameter settings for the estimator.
is_composite()Check if the object is composed of other BaseObjects.
load_from_path(serial)Load object from file location.
load_from_serial(serial)Load object from serialized memory container.
predict([fh, X])Forecast time series at future horizon.
predict_interval([fh, X, coverage])Compute/return prediction interval forecasts.
predict_proba([fh, X, marginal])Compute/return fully probabilistic forecasts.
predict_quantiles([fh, X, alpha])Compute/return quantile forecasts.
predict_residuals([y, X])Return residuals of time series forecasts.
predict_var([fh, X, cov])Compute/return variance forecasts.
pretrain(y[, X, fh])Pre-train forecaster on panel (global) data.
reset()Reset the object to a clean post-init state.
save([path, serialization_format])Save serialized self to bytes-like object or to (.zip) file.
score(y[, X, fh])Scores forecast against ground truth, using MAPE (non-symmetric).
set_config(**config_dict)Set config flags to given values.
set_params(**params)Set the parameters of this object.
set_random_state([random_state, deep, ...])Set random_state pseudo-random seed parameters for self.
set_tags(**tag_dict)Set instance level tag overrides to given values.
summary()Get a summary of the fitted forecaster.
update(y[, X, update_params])Update cutoff value and, optionally, fitted parameters.
update_predict(y[, cv, X, update_params, ...])Make predictions and update model iteratively over the test set.
update_predict_single([y, fh, X, update_params])Update model with new data and make forecasts.

