kats.models.arima module¶

The ARIMA model (stand for Auto Regressive Integrated Moving Average) is a classical statistical model for time series data

It contains three main components from its name - AR, Auto Regressive, means the variable of interest (time series) is regressed on its own lagged values - MA, Moving Average, means the regression error is a linear combination of error terms whose values occurred contemporaneously and at various times in the past - I, Integrated, means data values have been replaced with the difference between their values and the previous value We use the implementation in statsmodels <https://www.statsmodels.org/stable/index.html> and re-write the API to adapt Kats development style.

class kats.models.arima.ARIMAModel(data: kats.consts.TimeSeriesData, params: kats.models.arima.ARIMAParams)[source]¶

Bases: Generic[kats.models.model.ParamsType]

Model class for ARIMA model

data¶

kats.consts.TimeSeriesData, the input historical time series data from TimeSeriesData

params¶

The ARIMA model parameters from ARIMAParams

fit(start_params: Optional[numpy.ndarray] = None, transparams: bool = True, method: str = 'css-mle', trend: str = 'c', solver: str = 'lbfgs', maxiter: int = 500, full_output: bool = True, disp: int = 5, callback: Optional[Callable] = None, start_ar_lags: Optional[int] = None, **kwargs)None[source]¶

Fit ARIMA model with given parameters

For more details on each parameter please refer to the following doc: https://www.statsmodels.org/stable/generated/statsmodels.tsa.arima_model.ARIMA.fit.html#statsmodels.tsa.arima_model.ARIMA.fit

Parameters
  • start_params – Optional; An array_like object for the initial guess of the solution for the loglikelihood maximization

  • transparams – Optional; A boolean to specify whether or not to transform the parameters to ensure stationarity. Default is True

  • method – A string that specifies the loglikelihood to maximize. Can be ‘css-mle’, ‘mle’ and ‘css’. Default is ‘css-mle’

  • trend – A string that specifies the whether to include a constant in the trend or not. Can be ‘c’ and ‘nc’. Default is ‘c’

  • solver – Optional; A string that specifies specifies the solver to be used. Can be ‘bfgs’, ‘newton’, ‘cg’, ‘ncg’ and ‘powell’. Default is ‘bfgs’

  • maxiter – Optional; A integer for the maximum number of function iterations. Default is 500

  • tol – Optional; The convergence tolerance for the fitting. Default is 1e-08

  • full_output – Optional; A boolean to specify whether to show all output from the solver in the results. Default is True

  • disp – Optional; A integer to control the frequency of the output during the iterations. Default is 5

  • callback – Optional; A callable object to be called after each iteration. Default is None

  • Optional; An integer to specify the AR lag parameter to fit the start_params. Default is None (start_ar_lags) –

Returns

None

static get_parameter_search_space()List[Dict[str, Any]][source]¶

Get default ARIMA parameter search space.

Parameters

None –

Returns

A dictionary with the default ARIMA parameter search space

plot()[source]¶

Plot forecast results from the ARIMA model

predict(steps: int, include_history: bool = False, **kwargs)pandas.core.frame.DataFrame[source]¶

Predict with fitted ARIMA model

Parameters
  • steps – An integer for forecast steps

  • include_history – Optional; A boolearn to specify whether to include historical data. Default is False.

Returns

A pd.DataFrame that contains the forecast and confidence interval

class kats.models.arima.ARIMAParams(p: int, d: int, q: int, **kwargs)[source]¶

Bases: kats.consts.Params

Parameter class for ARIMA model

This is the parameter class for ARIMA model, it contains all necessary parameters from the following ARIMA implementation: https://www.statsmodels.org/stable/generated/statsmodels.tsa.arima_model.ARIMA.html

p¶

An integer for trend autoregressive (AR) order

d¶

An integer for trend difference order

q¶

An integer for trend moving average (MA) order

exog¶

Optional; An array of exogenous regressors

dates¶

Optional; pandas-compatible datetime object

freq¶

Optional; frequency of a given time series