Class ARMA

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

public class ARMA extends Object implements Serializable
Autoregressive moving-average model. ARMA models provide a parsimonious description of a (weakly) stationary stochastic process in terms of two polynomials, one for the autoregression (AR) and the second for the moving average (MA).

Given a time series of data, the ARMA model is a tool for understanding and, perhaps, predicting future values in this series. The AR part involves regressing the variable on its own lagged values. The MA part involves modeling the error term as a linear combination of error terms occurring contemporaneously and at various times in the past. The model is usually referred to as the ARMA(p,q) model where p is the order of the AR part and q is the order of the MA part.

See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    ARMA(double[] x, double[] ar, double[] ma, double b, double[] fittedValues, double[] residuals)
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    Returns adjusted R2 statistic.
    double[]
    ar()
    Returns the linear coefficients of AR(p).
    int
    df()
    Returns the degree-of-freedom of residual standard error.
    static ARMA
    fit(double[] x, int p, int q)
    Fits an ARMA model with Hannan-Rissanen algorithm.
    double[]
    Returns the fitted values.
    double
    Returns 1-step ahead forecast.
    double[]
    forecast(int l)
    Returns l-step ahead forecast.
    double
    Returns the intercept.
    double[]
    ma()
    Returns the linear coefficients of MA(q).
    double
    Returns the mean of time series.
    int
    p()
    Returns the order of AR.
    int
    q()
    Returns the order of MA.
    double
    R2()
    Returns R2 statistic.
    double[]
    Returns the residuals, that is response minus fitted values.
    double
    RSS()
    Returns the residual sum of squares.
     
    double[][]
    Returns the t-test of the coefficients (including intercept).
    double
    Returns the residual variance.
    double[]
    x()
    Returns the time series.

    Methods inherited from class java.lang.Object

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

    • ARMA

      public ARMA(double[] x, double[] ar, double[] ma, double b, double[] fittedValues, double[] residuals)
      Constructor.
      Parameters:
      x - the time series
      ar - the estimated weight parameters of AR(p).
      ma - the estimated weight parameters of MA(q).
      b - the intercept.
      fittedValues - the fitted values.
      residuals - the residuals.
  • Method Details

    • x

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

      public double mean()
      Returns the mean of time series.
      Returns:
      the mean of time series.
    • p

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

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

      public double[][] ttest()
      Returns the t-test of the coefficients (including intercept). The first column is the coefficients, the second column is the standard error of coefficients, the third column is the t-score of the hypothesis test if the coefficient is zero, the fourth column is the p-values of test. The last row is of intercept.
      Returns:
      the t-test of the coefficients.
    • ar

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

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

      public double intercept()
      Returns the intercept.
      Returns:
      the intercept.
    • residuals

      public double[] residuals()
      Returns the residuals, that is response minus fitted values.
      Returns:
      the residuals.
    • fittedValues

      public double[] fittedValues()
      Returns the fitted values.
      Returns:
      the fitted values.
    • 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 degree-of-freedom of residual standard error.
      Returns:
      the degree-of-freedom of residual standard error.
    • R2

      public double R2()
      Returns R2 statistic. In regression, the R2 coefficient of determination is a statistical measure of how well the regression line approximates the real data points. An R2 of 1.0 indicates that the regression line perfectly fits the data.

      In the case of ordinary least-squares regression, R2 increases as we increase the number of variables in the model (R2 will not decrease). This illustrates a drawback to one possible use of R2, where one might try to include more variables in the model until "there is no more improvement". This leads to the alternative approach of looking at the adjusted R2.

      Returns:
      R2 statistic.
    • adjustedR2

      public double adjustedR2()
      Returns adjusted R2 statistic. The adjusted R2 has almost same explanation as R2 but it penalizes the statistic as extra variables are included in the model.
      Returns:
      Adjusted R2 statistic.
    • fit

      public static ARMA fit(double[] x, int p, int q)
      Fits an ARMA model with Hannan-Rissanen algorithm.
      Parameters:
      x - the time series.
      p - the order of AR.
      q - the order of MA.
      Returns:
      the model.
    • forecast

      public double forecast()
      Returns 1-step ahead forecast.
      Returns:
      1-step ahead forecast.
    • forecast

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

      public String toString()
      Overrides:
      toString in class Object