Packages

class ARIMA extends Predictor with Error

The ARIMA class provides basic time series analysis capabilities for Auto- Regressive 'AR' Integrated 'I' Moving-Average 'MA' models. In an 'ARIMA(p, d, q)' model, 'p' and 'q' refer to the order of the Auto-Regressive and Moving-Average components of the model; 'd' refers to the order of differencing. ARIMA models are often used for forecasting. Given time series data stored in vector 'y', its next value 'y_t = y(t)' may be predicted based on prior values of 'y' and its noise:

y_t = c + Σ(φ_i y_t-i) + Σ(θ_i e_t-i) + e_t

where 'c' is a constant, 'φ' is the autoregressive coefficient vector, 'θ' is the moving-average coefficient vector, and 'e' is the noise vector. If 'd' > 0, then the time series must be differenced first before applying the above model. ------------------------------------------------------------------------------

Linear Supertypes
Error, Predictor, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. ARIMA
  2. Error
  3. Predictor
  4. AnyRef
  5. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new ARIMA(y: VectoD, t: VectoD, d: Int = 0)

    y

    the input vector (time series data)

    t

    the time vector

    d

    the order of Integration

Value Members

  1. val acf: VectorD
  2. def coefficient: VectoD

    Return the vector of coefficient/parameter values.

    Return the vector of coefficient/parameter values.

    Definition Classes
    Predictor
  3. def diagnose(yy: VectoD): Unit

    Compute diagostics for the predictor.

    Compute diagostics for the predictor. Override to add more diagostics. Note, for 'rmse', 'sse' is divided by the number of instances 'm' rather than degrees of freedom.

    yy

    the response vector

    Definition Classes
    Predictor
    See also

    en.wikipedia.org/wiki/Mean_squared_error

  4. def difference(): VectorD

    Difference the time series.

  5. def durbinLevinson: MatrixD

    Apply the Durbin-Levinson Algorithm to iteratively compute the 'psi' matrix.

    Apply the Durbin-Levinson Algorithm to iteratively compute the 'psi' matrix. The last row of the matrix gives 'AR' coefficients.

    See also

    www.stat.tamu.edu/~suhasini/teaching673/time_series.pdf

  6. def est_ar(p_: Int = 1): VectoD

    Estimate the coefficient vector 'φ' for a 'p'th order Auto-Regressive 'AR(p)' model.

    Estimate the coefficient vector 'φ' for a 'p'th order Auto-Regressive 'AR(p)' model.

    x_t = φ_0 * x_t-1 + ... + φ_p-1 * x_t-p + e_t

    Uses the Durbin-Levinson Algorithm to determine the coefficients. The 'φ' vector is 'p'th row of 'psi' matrix (ignoring the first (0th) column).

    p_

    the order of the AR model

  7. def est_arma(p_: Int = 1, q_: Int = 1): (VectoD, VectoD)

    Estimate the coefficient vectors φ and θ for a ('p'th, 'q'th) order Auto-Regressive Moving-Average 'ARIMA(p, q)' model.

    Estimate the coefficient vectors φ and θ for a ('p'th, 'q'th) order Auto-Regressive Moving-Average 'ARIMA(p, q)' model.

    x_t = φ_0 * x_t-1 + ... + φ_p-1 * x_t-p + θ_0 * e_t-1 + ... + θ_q-1 * e_t-q + e_t

    p_

    the order of the AR part of the model

    q_

    the order of the MA part of the model

    See also

    www.math.kth.se/matstat/gru/sf2943/tsform.pdf

  8. def est_ma(q_: Int = 1): VectoD

    Estimate the coefficient vector 'θ' for a 'q'th order a Moving-Average 'MA(q)' model.

    Estimate the coefficient vector 'θ' for a 'q'th order a Moving-Average 'MA(q)' model.

    x_t = θ_0 * e_t-1 + ... + θ_q-1 * e_t-q + e_t

    q_

    the order of the AR model

  9. def fit: VectoD

    Return the quality of fit including 'sse', 'mae', rmse' and 'rSq'.

    Return the quality of fit including 'sse', 'mae', rmse' and 'rSq'. Override to add more quality of fit measures.

    Definition Classes
    Predictor
  10. def fitLabels: Seq[String]

    Return the labels for the fit.

    Return the labels for the fit. Override when necessary.

    Definition Classes
    Predictor
  11. final def flaw(method: String, message: String): Unit
    Definition Classes
    Error
  12. def forecast_ar(steps: Int = 1): VectoD

    Produce the multi-step forecast for AR models.

  13. def forecast_arma(steps: Int = 1): VectoD

    Produce the one-step forecast for ARMA models

    Produce the one-step forecast for ARMA models

    steps

    the number of steps to forecast, must be at least one.

    See also

    ams.sunysb.edu/~zhu/ams586/Forecasting.pdf

  14. def forecast_ma(steps: Int = 1): VectoD

    Produce the one-step forecast for MA models

    Produce the one-step forecast for MA models

    steps

    the number of steps to forecast, must be at least one.

    See also

    ams.sunysb.edu/~zhu/ams586/Forecasting.pdf

  15. def hannanRissanen(): VectoD

    Apply the Hannan-Rissanen Algorithm to estimate the 'ARMA(p, q)' coefficients.

    Apply the Hannan-Rissanen Algorithm to estimate the 'ARMA(p, q)' coefficients.

    See also

    halweb.uc3m.es/esp/Personal/personas/amalonso/esp/TSAtema9.pdf

  16. def methodOfInnovations(): VectoD

    Apply the Method of Innovation to estimate coefficients for MA(q) model.

    Apply the Method of Innovation to estimate coefficients for MA(q) model.

    See also

    www.math.kth.se/matstat/gru/sf2943/tsform.pdf

    www.stat.berkeley.edu/~bartlett/courses/153-fall2010/lectures/10.pdf

  17. val mu: Double
  18. def obj_f(φθ: VectoD): Double

    Comput the objective function for MLE optimization.

    Comput the objective function for MLE optimization. FIX

    φθ

    a single vector of AR and MA coefficients

    See also

    halweb.uc3m.es/esp/Personal/personas/amalonso/esp/TSAtema9.pdf

  19. def optimize_MLE(): VectoD

    Apply the Hannan-Rissanen Algorithm first to estimate the 'ARIMA(p, q)' coefficients, then optimize the parameters using MLE.

    Apply the Hannan-Rissanen Algorithm first to estimate the 'ARIMA(p, q)' coefficients, then optimize the parameters using MLE. FIX

    See also

    halweb.uc3m.es/esp/Personal/personas/amalonso/esp/TSAtema9.pdf

  20. var pacf: VectoD
  21. def plotFunc(fVec: VectoD, name: String): Unit

    Plot a function, e.g., Auto-Correlation Function 'ACF', Partial Auto-Correlation Function 'PACF'.

    Plot a function, e.g., Auto-Correlation Function 'ACF', Partial Auto-Correlation Function 'PACF'.

    fVec

    the vector given function values

    name

    the name of the function

  22. def predict(t: VectoD): Double

    For the last time points in vector 't', predict the value of 'y = f(t)'.

    For the last time points in vector 't', predict the value of 'y = f(t)'.

    t

    the time-vector indicating time points to forecast

    Definition Classes
    ARIMAPredictor
  23. def predict(z: VectoI): Double

    Given a new discrete data vector z, predict the y-value of f(z).

    Given a new discrete data vector z, predict the y-value of f(z).

    z

    the vector to use for prediction

    Definition Classes
    Predictor
  24. def predictAll: VectoD

    For all the time points, predict all the values of 'y = f(t)'.

  25. def predict_ar(transBack: Boolean = true): VectoD

    Return a vector that is the predictions of a 'p'th order Auto-Regressive 'AR(p)' model.

    Return a vector that is the predictions of a 'p'th order Auto-Regressive 'AR(p)' model.

    transBack

    flag that determines whether to return the predicted values in the original scale

  26. def predict_arma(transBack: Boolean = true): VectoD

    Return a vector that is the predictions of a ('p'th, 'q'th) order Auto-Regressive Moving-Average 'ARMA(p, q)' model.

    Return a vector that is the predictions of a ('p'th, 'q'th) order Auto-Regressive Moving-Average 'ARMA(p, q)' model.

    transBack

    flag that determines whether to return the predicted values in the original scale

  27. def predict_ma(transBack: Boolean = true): VectoD

    Return a vector of predictions of an MA model and update the residuals

    Return a vector of predictions of an MA model and update the residuals

    transBack

    flag that determines whether to return the predicted values in the original scale

  28. def residual: VectoD

    Return the vector of residuals/errors.

    Return the vector of residuals/errors.

    Definition Classes
    Predictor
  29. def setPQ(p_: Int, q_: Int): Unit

    Set values for 'p' and 'q'.

    Set values for 'p' and 'q'.

    p_

    the order of the AR part of the model

    q_

    the order of the MA part of the model

  30. def smooth(l: Int): VectoD

    Smooth the 'y' vector by taking the 'l'th order moving average.

    Smooth the 'y' vector by taking the 'l'th order moving average.

    l

    the number of points to average

  31. def train(): Unit

    Train/fit an ARIMA model to the times series data on 'y'.

    Train/fit an ARIMA model to the times series data on 'y'.

    Definition Classes
    ARIMAPredictor
  32. def train(yy: VectoD): Unit

    Train/fit an ARIMA model to times the series data.

    Train/fit an ARIMA model to times the series data. Must call setPQ first.

    yy

    the response vector

    Definition Classes
    ARIMAPredictor
  33. def transformBack(xp: VectoD): VectoD

    Transform the predictions/fitted values of a differenced time series back to the original scale.

    Transform the predictions/fitted values of a differenced time series back to the original scale.

    xp

    the vector of predictions/fitted values of a differenced time series

    See also

    stats.stackexchange.com/questions/32634/difference-time-series-before-arima-or-within-arima

  34. def transformBack_f(xf: VectoD): VectoD

    Transform the forecasted values of a differenced time series back to the original scale.

    Transform the forecasted values of a differenced time series back to the original scale.

    xf

    the vector of forecasted values of a differenced time series

    See also

    stats.stackexchange.com/questions/32634/difference-time-series-before-arima-or-within-arima