pyamr.core.regression.arima pyamr.core.regression.arima =========================== ===========================

Classes

class pyamr.core.regression.arima.ARIMAWrapper(estimator=None, evaluate=True)[source]

Methods:

as_summary(**kwargs)

Returns a summary string (statsmodels inspired)

auto(endog[, exog, ic, trends, max_ar, ...])

Find the best model through bruteforce.

conf_int_forecast(predictions[, alpha])

Computes the out-sample confidence interval.

evaluate([alpha])

Generates a dictionary with the relevant attributes.

get_prediction([start, end, alpha])

Calls the predict function in ARIMA.

as_summary(**kwargs)[source]

Returns a summary string (statsmodels inspired)

auto(endog, exog=None, ic='bic', trends=['n', 'c'], max_ar=3, max_ma=3, max_d=1, warn='ignore', return_fits=False, converged=True, disp=0, verbose=0, **kwargs)[source]

Find the best model through bruteforce.

Note: It uses grid search through the base wrapper.

Parameters:
  • endog (array-like) – The endogenous variable (aka. time series data)

  • exog (array-like) – The exogenous variable (by default is the time t starting in 0)

  • ic (string) – The information criteria which should be any of the params which are set in the wrapper (see method _init_result).

  • max_ar (number) – The maximum autorregresive order to inspect.

  • max_ma (number) – The maximum moving average order to inspect.

  • max_d (number) – The maximum difference to inspect.

  • warn (string, options = {ignore, raise}) – Whether or not to ignore the warnings raised

  • return_fits (bool) – Whether or not to return all the fits. If false only the best model is returned. If true all the models and the best model are returned separately.

  • converged (bool) – Whether or not to return only converging models. If false all models are returned. If true, only those models that converged are returned.

conf_int_forecast(predictions, alpha=0.05)[source]

Computes the out-sample confidence interval.

Parameters:
  • predictions (array-like) – The predictions done by the model.

  • alpha (int) – The alpha to configure the confidence interval.

Return type:

array-like

evaluate(alpha=0.05)[source]

Generates a dictionary with the relevant attributes.

Note

There is an issue with the method conf_int(alpha). It can receive as input parameters a pandas series or a numpy array. We are using it with numpy array as input, hence when pandas series is passed the method _init_result gives an error.

statsmodels:Arima statsmodels:ArimaResults

Parameters:

alpha (the confidence interval.)

Returns:

dictionary

Return type:

map with all the parameters.

get_prediction(start=None, end=None, alpha=0.05, **kwargs)[source]

Calls the predict function in ARIMA.

Note

The confidence intervals have been implemented using the following functions _forecast_conf_int() and _forecast_error(). These are implemented in statsmodels.ts.arima_model.ARIMAResults. As such, it produces the same confidence intervals than the method plot_predict().

Note

The parameter start refers to the original series. As such, if the series has been differenced (e.g. d=1) the first observation has been lost. In those cases, start has to be greater or equal to d.

Todo

  • Review the predictions when dynamic is set to true.

  • Review the confidence intervals (in and out sample)

  • Review the prediction intervals.

Parameters:
  • start (int (optional)) – The time t to start the prediction

  • end (int (optional)) – The time t to end the prediction

  • dynamic (bool) – The dynamic keyword affects in-sample prediction. If dynamic is false then the in-sample lagged values are used for prediction. if dynamic is true, then in-sample forecasts are used in place of lagged dependent variables. The first forecasted value is start.

  • alpha (float) – The alpha value when creating the norm point percent function to compute the confidence intervals for the forecast predictions.

  • typ (string-like, options = {linear, levels}) – Wether to predict the original levels (levels) or predict in terms of the differenced endogenous variables.

Return type:

matrix

Examples using pyamr.core.regression.arima.ARIMAWrapper

Step 04 - TSA to estimate trends

Step 04 - TSA to estimate trends

Using autoregressive model ARIMA

Using autoregressive model ARIMA

ARIMA - Basic

ARIMA - Basic

ARIMA - Search

ARIMA - Search