Class ARIMA

java.lang.Object
smile.timeseries.ARIMA
All Implemented Interfaces:
Serializable

public class ARIMA extends Object implements Serializable
Autoregressive integrated moving average (ARIMA) model. An ARIMA model generalizes the autoregressive moving-average (ARMA) model to non-stationary time series by applying differencing one or more times to eliminate trend and achieve stationarity.

The model is conventionally denoted as ARIMA(p, d, q), where:

  • p is the order of the autoregressive (AR) part,
  • d is the degree of differencing (the integrated part),
  • q is the order of the moving-average (MA) part.

Given a time series \(X_t\), the differenced series is: \[ Y_t = (1 - B)^d X_t = \Delta^d X_t \] where \(B\) is the backshift operator (\(B X_t = X_{t-1}\)). An \(\text{ARMA}(p, q)\) process is then fitted to \(Y_t\): \[ Y_t = c + \sum_{i=1}^p \phi_i Y_{t-i} + \epsilon_t + \sum_{j=1}^q \theta_j \epsilon_{t-j} \] When forecasting future values, predictions are first generated on the differenced series and then integrated (undifferenced) back to the original level of the series.

References

  1. George E. P. Box, Gwilym M. Jenkins, Gregory C. Reinsel, and Greta M. Ljung. Time Series Analysis: Forecasting and Control. 5th edition, John Wiley & Sons, 2015.
  2. Peter J. Brockwell and Richard A. Davis. Introduction to Time Series and Forecasting. 3rd edition, Springer, 2016.
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    ARIMA(double[] x, int p, int d, int q, ARMA arma, double[][] diff)
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    Returns the adjusted R2 on the fitted series.
    double
    aic()
    Returns the Akaike information criterion (AIC).
    double[]
    ar()
    Returns the linear coefficients of AR(p).
    Returns the underlying ARMA model on the differenced series.
    double
    bic()
    Returns the Bayesian information criterion (BIC).
    int
    d()
    Returns the degree of differencing.
    int
    df()
    Returns the degrees of freedom of residual variance.
    static ARIMA
    fit(double[] x, int p, int q)
    Fits an ARIMA(p, 0, q) model without differencing (equivalent to ARMA(p, q)).
    static ARIMA
    fit(double[] x, int p, int d, int q)
    Fits an ARIMA(p, d, q) model.
    double[]
    Returns in-sample fitted values on the original series scale.
    double
    Returns 1-step ahead forecast on the original scale.
    double[]
    forecast(int l)
    Returns l-step ahead forecast on the original scale.
    double
    Returns the intercept / drift term.
    double
    Returns the log-likelihood of the model under Gaussian errors.
    double[]
    ma()
    Returns the linear coefficients of MA(q).
    double
    Returns the mean of the fitted (differenced) series.
    int
    p()
    Returns the order of AR.
    int
    q()
    Returns the order of MA.
    double
    R2()
    Returns the coefficient of determination R2 on the fitted series.
    double[]
    Returns in-sample residuals on the original series scale.
    double
    RSS()
    Returns the residual sum of squares.
     
    double[][]
    Returns the hypothesis testing of the coefficients.
    double
    Returns the residual variance.
    double[]
    x()
    Returns the original time series.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • ARIMA

      public ARIMA(double[] x, int p, int d, int q, ARMA arma, double[][] diff)
      Constructor.
      Parameters:
      x - the original time series.
      p - the order of AR.
      d - the degree of differencing.
      q - the order of MA.
      arma - the underlying ARMA model.
      diff - the intermediate differencing stages.
  • Method Details

    • x

      public double[] x()
      Returns the original time series.
      Returns:
      the original time series.
    • p

      public int p()
      Returns the order of AR.
      Returns:
      the order of AR.
    • d

      public int d()
      Returns the degree of differencing.
      Returns:
      the degree of differencing.
    • q

      public int q()
      Returns the order of MA.
      Returns:
      the order of MA.
    • arma

      public ARMA arma()
      Returns the underlying ARMA model on the differenced series.
      Returns:
      the ARMA model.
    • mean

      public double mean()
      Returns the mean of the fitted (differenced) series.
      Returns:
      the mean.
    • ar

      public double[] ar()
      Returns the linear coefficients of AR(p).
      Returns:
      the AR coefficients.
    • ma

      public double[] ma()
      Returns the linear coefficients of MA(q).
      Returns:
      the MA coefficients.
    • intercept

      public double intercept()
      Returns the intercept / drift term.
      Returns:
      the intercept.
    • fittedValues

      public double[] fittedValues()
      Returns in-sample fitted values on the original series scale.
      Returns:
      in-sample fitted values.
    • residuals

      public double[] residuals()
      Returns in-sample residuals on the original series scale.
      Returns:
      in-sample residuals.
    • RSS

      public double RSS()
      Returns the residual sum of squares.
      Returns:
      the residual sum of squares.
    • variance

      public double variance()
      Returns the residual variance.
      Returns:
      the residual variance.
    • df

      public int df()
      Returns the degrees of freedom of residual variance.
      Returns:
      the degrees of freedom.
    • R2

      public double R2()
      Returns the coefficient of determination R2 on the fitted series.
      Returns:
      R2.
    • adjustedR2

      public double adjustedR2()
      Returns the adjusted R2 on the fitted series.
      Returns:
      adjusted R2.
    • logLikelihood

      public double logLikelihood()
      Returns the log-likelihood of the model under Gaussian errors.
      Returns:
      the log-likelihood.
    • aic

      public double aic()
      Returns the Akaike information criterion (AIC).
      Returns:
      the AIC.
    • bic

      public double bic()
      Returns the Bayesian information criterion (BIC).
      Returns:
      the BIC.
    • ttest

      public double[][] ttest()
      Returns the hypothesis testing of the coefficients.
      Returns:
      the hypothesis testing table.
    • fit

      public static ARIMA fit(double[] x, int p, int d, int q)
      Fits an ARIMA(p, d, q) model.
      Parameters:
      x - the time series.
      p - the order of AR.
      d - the degree of differencing.
      q - the order of MA.
      Returns:
      the fitted ARIMA model.
    • fit

      public static ARIMA fit(double[] x, int p, int q)
      Fits an ARIMA(p, 0, q) model without differencing (equivalent to ARMA(p, q)).
      Parameters:
      x - the time series.
      p - the order of AR.
      q - the order of MA.
      Returns:
      the fitted ARIMA model.
    • forecast

      public double forecast()
      Returns 1-step ahead forecast on the original scale.
      Returns:
      1-step ahead forecast.
    • forecast

      public double[] forecast(int l)
      Returns l-step ahead forecast on the original scale.
      Parameters:
      l - the number of forecast steps.
      Returns:
      l-step ahead forecast.
    • toString

      public String toString()
      Overrides:
      toString in class Object