ARIMA
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. 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 = δ + Σ(φ_i y_t-i) + Σ(θ_i e_t-i) + e_t
where δ is a constant, φ is the auto-regressive 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.
Value parameters
- bakcast
-
whether a backcasted value is prepended to the time series (defaults to false)
- hh
-
the maximum forecasting horizon (h = 1 to hh)
- hparam
-
the hyper-parameters (defaults to AR.hp)
- tRng
-
the time range, if relevant (time index may suffice)
- y
-
the response vector (time series data)
Attributes
- Graph
-
- Supertypes
-
class ARMAclass ARtrait Correlogramclass Forecastertrait Modeltrait ForecastMatrixclass Diagnosertrait Fittrait FitMclass Objecttrait Matchableclass AnyShow all
Members list
Value members
Concrete methods
Predict all values corresponding to the given vector v_. If differenced, tranform back to the original scale.
Predict all values corresponding to the given vector v_. If differenced, tranform back to the original scale.
Value parameters
- v_
-
the actual values to use in making predictions (as passed to ARMA).
Attributes
Inherited methods
Return the autocorrelation vector (ACF).
Align the actual response vector for comparison with the predicted/forecasted response vector, returning a time vector and sliced response vector.
Align the actual response vector for comparison with the predicted/forecasted response vector, returning a time vector and sliced response vector.
Value parameters
- tr_size
-
the size of the intial training set
- y
-
the actual response for the full dataset (to be sliced)
Attributes
- Inherited from:
- Forecaster
Return the maximum lag used by the model (its capacity to look into the past). Models that use more than one past value to make predictions/forecasts must override this method, e.g., ARMA (2, 3) should set the cap to max(p, q) = 3.
Return the maximum lag used by the model (its capacity to look into the past). Models that use more than one past value to make predictions/forecasts must override this method, e.g., ARMA (2, 3) should set the cap to max(p, q) = 3.
Attributes
- Inherited from:
- Forecaster
Attributes
- Inherited from:
- Forecaster
Diagnose the health of the model by computing the Quality of Fit (QoF) measures, from the error/residual vector and the predicted & actual responses. For some models the instances may be weighted. For time series, the first few predictions use only part of the model, so may be skipped.
Diagnose the health of the model by computing the Quality of Fit (QoF) measures, from the error/residual vector and the predicted & actual responses. For some models the instances may be weighted. For time series, the first few predictions use only part of the model, so may be skipped.
Value parameters
- w
-
the weights on the instances (defaults to null)
- y
-
the actual response/output vector to use (test/full)
- yp
-
the predicted response/output vector (test/full)
Attributes
- Definition Classes
- Inherited from:
- Diagnoser
Diagnose the health of the model by computing the Quality of Fit (QoF) measures, for all horizons and print the results in a table. For time series, the first few predictions use only part of the model, so may be skipped. The version is for models that perform DIRECT multi-horizon forecasting.
Diagnose the health of the model by computing the Quality of Fit (QoF) measures, for all horizons and print the results in a table. For time series, the first few predictions use only part of the model, so may be skipped. The version is for models that perform DIRECT multi-horizon forecasting.
Value parameters
- yf
-
the entire FORECAST MATRIX
- yy
-
the actual response/output matrix over all horizons
Attributes
- Inherited from:
- ForecastMatrix
Diagnose the health of the model by computing the Quality of Fit (QoF) measures, for all horizons and print the results in a table. For time series, the first few predictions use only part of the model, so may be skipped. The version is for models that perform RECURSIVE multi-horizon forecasting.
Diagnose the health of the model by computing the Quality of Fit (QoF) measures, for all horizons and print the results in a table. For time series, the first few predictions use only part of the model, so may be skipped. The version is for models that perform RECURSIVE multi-horizon forecasting.
Value parameters
- rRng
-
the time range, defaults to null (=> full time range)
- sft
-
the amount of shift for yfh (FIX - ideally unify the code and remove sft)
- showYf
-
the amount of shift for yfh (FIX - ideally unify the code and remove sft)
- y_
-
the actual response/output vector
- yf
-
the entire FORECAST MATRIX
Attributes
- Inherited from:
- ForecastMatrix
Diagnose the health of the model by computing the Quality of Fit (QoF) metrics/measures, from the error/residual vector and the predicted & actual responses. For some models the instances may be weighted. Include interval measures. Note: wis
should be computed separately.
Diagnose the health of the model by computing the Quality of Fit (QoF) metrics/measures, from the error/residual vector and the predicted & actual responses. For some models the instances may be weighted. Include interval measures. Note: wis
should be computed separately.
Value parameters
- alpha
-
the nominal level of uncertainty (alpha) (defaults to 0.9, 90%)
- low
-
the predicted lower bound
- up
-
the predicted upper bound
- w
-
the weights on the instances (defaults to null)
- y
-
the actual response/output vector to use (test/full)
- yp
-
the point prediction mean/median
Attributes
- See also
-
Regression_WLS
- Inherited from:
- Fit
Diagnose the health of the model by computing the Quality of Fit (QoF) measures,
Diagnose the health of the model by computing the Quality of Fit (QoF) measures,
Value parameters
- alphas
-
the array of prediction levels
- low
-
the lower bounds for various alpha levels
- up
-
the upper bounds for various alpha levels
- y
-
the given time-series (must be aligned with the interval forecast)
- yp
-
the point prediction mean/median
Attributes
- Inherited from:
- Fit
Apply the Durbin-Levinson Algorithm to iteratively compute the psi matrix. The last/p-th row of the matrix gives AR coefficients. Note, also known as Levinson-Durbin.
Apply the Durbin-Levinson Algorithm to iteratively compute the psi matrix. The last/p-th row of the matrix gives AR coefficients. Note, also known as Levinson-Durbin.
Value parameters
- g
-
the auto-covariance vector (gamma)
- ml
-
the maximum number of lags
Attributes
- See also
- Inherited from:
- Correlogram
Return the Quality of Fit (QoF) measures corresponding to the labels given. Note, if sse > sst, the model introduces errors and the rSq may be negative, otherwise, R^2 (rSq) ranges from 0 (weak) to 1 (strong). Override to add more quality of fit measures.
Return the Quality of Fit (QoF) measures corresponding to the labels given. Note, if sse > sst, the model introduces errors and the rSq may be negative, otherwise, R^2 (rSq) ranges from 0 (weak) to 1 (strong). Override to add more quality of fit measures.
Attributes
- Definition Classes
- Inherited from:
- Fit
Produce a vector of size hh, h = 1 to hh-steps ahead forecasts for the model, i.e., forecast the following time points: t+1, ..., t+h. Intended to work with rolling validation (analog of predict method). Note, must include [ y_i, e_i ] before horizon and [ yp_i ] after horizon
Produce a vector of size hh, h = 1 to hh-steps ahead forecasts for the model, i.e., forecast the following time points: t+1, ..., t+h. Intended to work with rolling validation (analog of predict method). Note, must include [ y_i, e_i ] before horizon and [ yp_i ] after horizon
Value parameters
- t
-
the time point from which to make forecasts
- y_
-
the actual values to use in making predictions
Attributes
- Definition Classes
- Inherited from:
- ARMA
Forecast values for all y_.dim time points and all horizons (1 through hh-steps ahead). Record these in the FORECAST MATRIX yf, where
Forecast values for all y_.dim time points and all horizons (1 through hh-steps ahead). Record these in the FORECAST MATRIX yf, where
yf(t, h) = h-steps ahead forecast for y_t
Value parameters
- y_
-
the actual values to use in making forecasts
Attributes
- Inherited from:
- Forecaster
Forecast values for all y_.dim time points at horizon h (h-steps ahead). Assign into FORECAST MATRIX and return the h-steps ahead forecast. Note, predictAll
provides predictions for h = 1.
Forecast values for all y_.dim time points at horizon h (h-steps ahead). Assign into FORECAST MATRIX and return the h-steps ahead forecast. Note, predictAll
provides predictions for h = 1.
Value parameters
- h
-
the forecasting horizon, number of steps ahead to produce forecasts
- y_
-
the actual values to use in making forecasts
Attributes
- See also
-
forecastAll
method inForecaster
trait. Note, must include [ y_i, e_i ] before horizon and [ yp_i ] after horizon - Definition Classes
- Inherited from:
- ARMA
Forecast intervals for all y_.dim time points at horizon h (h-steps ahead). Create prediction intervals (two vectors) for the given time points at level p. Caveat: assumes errors follow a Normal distribution. Override this method to handle other cases.
Forecast intervals for all y_.dim time points at horizon h (h-steps ahead). Create prediction intervals (two vectors) for the given time points at level p. Caveat: assumes errors follow a Normal distribution. Override this method to handle other cases.
Value parameters
- h
-
the forecasting horizon, number of steps ahead to produce forecasts
- p
-
the level (1 - alpha) for the prediction interval
- y_
-
the aligned actual values to use in making forecasts
- yfh
-
the forecast vector at horizon h
Attributes
- Inherited from:
- Forecaster
Forge a vector from va;ues in the FORECAST MATRIX yf.
Forge a vector from va;ues in the FORECAST MATRIX yf.
Value parameters
- h
-
the forecasting horizon
- t
-
the time point from which to make forecasts
Attributes
- Inherited from:
- AR
Return the feature/variable names. Override for models like SARIMAX.
Return the feature/variable names. Override for models like SARIMAX.
Attributes
- Inherited from:
- Forecaster
Return the used data/input matrix. Model that use x should override.
Return the used data/input matrix. Model that use x should override.
Attributes
- Inherited from:
- Forecaster
Return the used response/output vector y.
Return the the y-transformation.
Return the used response matrix y, if needed.
Return the used response matrix y, if needed.
Attributes
- See also
-
neuralnet.PredictorMV
- Inherited from:
- Model
Return the used response/output vector yb (y prepended by one backcast value).
Return the used response/output vector yb (y prepended by one backcast value).
Attributes
- Inherited from:
- Forecaster
Return the used FORECAST MATRIX yf.
Return the help string that describes the Quality of Fit (QoF) measures provided by the Fit
trait. Override to correspond to fitLabel.
Return the hyper-parameters.
Perform In-Sample Testing (In-ST), i.e. train and test on the full data set.
Perform In-Sample Testing (In-ST), i.e. train and test on the full data set.
Value parameters
- showYf
-
whether to show the forecast matrix
- skip
-
the number of initial time points to skip (due to insufficient past)
Attributes
- Inherited from:
- Forecaster
Initialize the model parameters b = φ ++ θ by use the inherited AR for φ and small random numbers for θ.
Initialize the model parameters b = φ ++ θ by use the inherited AR for φ and small random numbers for θ.
Value parameters
- y_
-
the training/full response vector (e.g., full y)
Attributes
- Inherited from:
- ARMA
The log-likelihood function times -2. Override as needed.
The log-likelihood function times -2. Override as needed.
Value parameters
- ms
-
raw Mean Squared Error
- s2
-
MLE estimate of the population variance of the residuals
Attributes
- See also
- Inherited from:
- Fit
Make a Correlogram, i.e., compute stats, psi and pacf.
Make a Correlogram, i.e., compute stats, psi and pacf.
Value parameters
- y_
-
the current (e.g., training) times-series to use (defaults to full y)
Attributes
- Inherited from:
- Correlogram
Make the full FORECAST MATRIX where the zeroth column holds the actual time series and the last column is its time/time index. Columns 1, 2, ... hh are for h steps ahead forecasts.
Make the full FORECAST MATRIX where the zeroth column holds the actual time series and the last column is its time/time index. Columns 1, 2, ... hh are for h steps ahead forecasts.
Value parameters
- hh
-
the maximum forecasting horizon, number of steps ahead to produce forecasts
- y_
-
the actual time series vector to use in making forecasts
Attributes
- Inherited from:
- ForecastMatrix
Models need to provide a means for updating the Degrees of Freedom (DF).
Models need to provide a means for updating the Degrees of Freedom (DF).
Value parameters
- size
-
the size of dataset (full, train, or test)
Attributes
- Definition Classes
- Inherited from:
- Forecaster
Return the mean of the squares for error (sse / df). Must call diagnose first.
Return the mean of the squares for error (sse / df). Must call diagnose first.
Attributes
- Inherited from:
- Fit
Attributes
- Inherited from:
- Forecaster
Return the partial autocorrelation vector (PACF).
Return the parameter vector for the AR(p) model.
Plot both the Auto-Correlation Function (ACF) and the Partial Auto-Correlation Function (PACF) with confidence bound.
Plot both the Auto-Correlation Function (ACF) and the Partial Auto-Correlation Function (PACF) with confidence bound.
Value parameters
- show
-
whether to show the ACF, PACF values
Attributes
- Inherited from:
- Correlogram
Plot a function, e.g., Auto-Correlation Function (ACF), Partial Auto-Correlation Function (PACF) with confidence bound.
Plot a function, e.g., Auto-Correlation Function (ACF), Partial Auto-Correlation Function (PACF) with confidence bound.
Value parameters
- fVec
-
the vector given function values
- name
-
the name of the function
- show
-
whether to show the fVec values
Attributes
- Inherited from:
- Correlogram
Predict a value for y_t using the 1-step ahead forecast.
Predict a value for y_t using the 1-step ahead forecast.
y_t = δ + φ_0 y_t-1 + φ_1 y_t-2 + ... + φ_p-1 y_t-p
θ_0 e_t-1 + θ_1 e_t-2 + ... + θ_q-1 e_t-q
where φ = b(0 until p) and θ = b(p until p_q). When k < 0 let y_k = y_0 (i.e., assume first value repeats back in time), but do not assume errors repeat. Note, column 1 of yf (yf(?, 1) holds yp. Must be executed in time order, so errors are properly recorded in vector e
Value parameters
- t
-
the time point being predicted
- y_
-
the actual values to use in making predictions
Attributes
- See also
-
predictAll
method inForecaster
trait.rdot
in Forecaster.scala for reverse dot product implementation. - Definition Classes
- Inherited from:
- ARMA
The standard signature for prediction does not apply to time series.
The standard signature for prediction does not apply to time series.
Attributes
- Inherited from:
- Forecaster
Predict all values corresponding to the given time series vector y_. Update FORECAST MATRIX yf and return PREDICTION VECTOR yp as second (1) column of yf with last value removed.
Predict all values corresponding to the given time series vector y_. Update FORECAST MATRIX yf and return PREDICTION VECTOR yp as second (1) column of yf with last value removed.
Value parameters
- y_
-
the actual time series values to use in making predictions
Attributes
- See also
-
forecastAll
to forecast beyond horizon h = 1. - Inherited from:
- Forecaster
Return the psi matrix.
Return the coefficient of determination (R^2). Must call diagnose first.
Return the coefficient of determination (R^2). Must call diagnose first.
Attributes
- Inherited from:
- FitM
Return a basic report on a trained and tested multi-variate model.
Return a basic report on a trained and tested multi-variate model.
Value parameters
- ftMat
-
the matrix of qof values produced by the
Fit
trait
Attributes
- Inherited from:
- Model
Return a basic report on a trained and tested model.
Return a basic report on a trained and tested model.
Value parameters
- ftVec
-
the vector of qof values produced by the
Fit
trait
Attributes
- Inherited from:
- Model
Reset the degrees of freedom to the new updated values. For some models, the degrees of freedom is not known until after the model is built.
Reset the degrees of freedom to the new updated values. For some models, the degrees of freedom is not known until after the model is built.
Value parameters
- df_update
-
the updated degrees of freedom (model, error)
Attributes
- Inherited from:
- Fit
Use a higher order AR model to estimate the residuals (unobserved data). Set the residual/error vector e defined in Forecaster
.
Use a higher order AR model to estimate the residuals (unobserved data). Set the residual/error vector e defined in Forecaster
.
Value parameters
- y_
-
the training/full response vector (e.g., full y)
Attributes
- Inherited from:
- ARMA
Return the vector of residuals/errors.
Use rolling-validation to compute test Quality of Fit (QoF) measures by dividing the dataset into a TRAINING SET (tr) and a TESTING SET (te). as follows: [ <-- tr_size --> | <-- te_size --> ] Calls forecast for h-steps ahead out-of-sample forecasts. Return the FORECAST MATRIX.
Use rolling-validation to compute test Quality of Fit (QoF) measures by dividing the dataset into a TRAINING SET (tr) and a TESTING SET (te). as follows: [ <-- tr_size --> | <-- te_size --> ] Calls forecast for h-steps ahead out-of-sample forecasts. Return the FORECAST MATRIX.
Value parameters
- growing
-
whether the training grows as it roll or kepps a fixed size
- rc
-
the retraining cycle (number of forecasts until retraining occurs)
Attributes
- Inherited from:
- Forecaster
Set the number of data points/elements to skip at the beginning of a time series for purposes of diagnosis or computing a loss function. For In-Sample, the first value (time t = 0) is not forecastable without backcasting.
Set the number of data points/elements to skip at the beginning of a time series for purposes of diagnosis or computing a loss function. For In-Sample, the first value (time t = 0) is not forecastable without backcasting.
Value parameters
- skip
-
skip this many elements at the beginning of the time series
Attributes
- Inherited from:
- Diagnoser
Show the prediction interval forecasts and relevant QoF metrics/measures.
Show the prediction interval forecasts and relevant QoF metrics/measures.
Value parameters
- h
-
the forecasting horizon
- low
-
the predicted lower bound
- qof_all
-
all the QoF metrics (for point and interval forecasts)
- up
-
the predicted upper bound
- yfh
-
the forecasts for horizon h
- yy
-
the aligned actual response/output vector to use (test/full)
Attributes
- Inherited from:
- Fit
Return the slanted/diagonalized-down version of the forecast matrix where each row is at a fixed time point and, for example, the random walk model simply pushes the values down diagonals. Note unshiftDiag
reverses the process. Also reset the last column that holds the time index to 0, 1, 2, 3, ...
Return the slanted/diagonalized-down version of the forecast matrix where each row is at a fixed time point and, for example, the random walk model simply pushes the values down diagonals. Note unshiftDiag
reverses the process. Also reset the last column that holds the time index to 0, 1, 2, 3, ...
Value parameters
- yf
-
the current forecast matrix
Attributes
- Inherited from:
- ForecastMatrix
Return the symmetric Mean Absolute Percentage Error (sMAPE) score. Caveat: y_i = yp_i = 0 => no error => no percentage error
Return the symmetric Mean Absolute Percentage Error (sMAPE) score. Caveat: y_i = yp_i = 0 => no error => no percentage error
Value parameters
- e_
-
the error/residual vector (if null, recompute)
- y
-
the given time-series (must be aligned with the forecast)
- yp
-
the forecasted time-series
Attributes
- Inherited from:
- FitM
Return the sum of squared errors (loss function).
Return the sum of squared errors (loss function).
Value parameters
- b_
-
the combined parameters (δ, b) where b = (φ, θ).
Attributes
- Inherited from:
- ARMA
Return the sum of the squares for error (sse). Must call diagnose first.
Return the sum of the squares for error (sse). Must call diagnose first.
Attributes
- Inherited from:
- FitM
Compute the sum of squares errors (loss function), assuming the first 'skip' errors are zero.
Compute the sum of squares errors (loss function), assuming the first 'skip' errors are zero.
Value parameters
- y
-
the actual response vector
- yp
-
the predicted response vector (one-step ahead)
Attributes
- Inherited from:
- Diagnoser
Return basic statistics on time-series y or y_.
Produce a QoF summary for a model with diagnostics for each predictor x_j and the overall Quality of Fit (QoF). Note: `Fac_Cholesky is used to compute the inverse of xtx.
Produce a QoF summary for a model with diagnostics for each predictor x_j and the overall Quality of Fit (QoF). Note: `Fac_Cholesky is used to compute the inverse of xtx.
Value parameters
- b
-
the parameters/coefficients for the model
- fname
-
the array of feature/variable names
- vifs
-
the Variance Inflation Factors (VIFs)
- x_
-
the testing/full data/input matrix
Attributes
- Definition Classes
- Inherited from:
- Fit
Test PREDICTIONS of a forecasting model y_ = f(lags (y_)) + e and return its predictions and QoF vector. Testing may be in-sample (on the training set) or out-of-sample (on the testing set) as determined by the parameters passed in. Note: must call train before test. Must override to get Quality of Fit (QoF).
Test PREDICTIONS of a forecasting model y_ = f(lags (y_)) + e and return its predictions and QoF vector. Testing may be in-sample (on the training set) or out-of-sample (on the testing set) as determined by the parameters passed in. Note: must call train before test. Must override to get Quality of Fit (QoF).
Value parameters
- x_null
-
the data/input matrix (ignored, pass null)
- y_
-
the actual testing/full response/output vector
Attributes
- Inherited from:
- Forecaster
Test FORECASTS of a forecasting model y_ = f(lags (y_)) + e and RETURN (1) aligned actual values, (2) its forecasts and (3) QoF vector. Testing may be in-sample (on the training set) or out-of-sample (on the testing set) as determined by the parameters passed in. Note: must call train and forecastAll before testF.
Test FORECASTS of a forecasting model y_ = f(lags (y_)) + e and RETURN (1) aligned actual values, (2) its forecasts and (3) QoF vector. Testing may be in-sample (on the training set) or out-of-sample (on the testing set) as determined by the parameters passed in. Note: must call train and forecastAll before testF.
Value parameters
- h
-
the forecasting horizon, number of steps ahead to produce forecasts
- y_
-
the testing/full response/output vector
Attributes
- Inherited from:
- Forecaster
Train/fit an ARMA
model to the times-series data in vector y_. Estimate the coefficient vector b for a (p, q)-th order Auto-Regressive ARMA(p, q) model. Uses a nonlinear optimizer (e.g., LBFGS_B) to determine the coefficients. Residuals are estimated before optimization using the Hannan-Rissanen Algorithm. NOTE: Requires the error update in predict
to be commented out.
Train/fit an ARMA
model to the times-series data in vector y_. Estimate the coefficient vector b for a (p, q)-th order Auto-Regressive ARMA(p, q) model. Uses a nonlinear optimizer (e.g., LBFGS_B) to determine the coefficients. Residuals are estimated before optimization using the Hannan-Rissanen Algorithm. NOTE: Requires the error update in predict
to be commented out.
Value parameters
- x_null
-
the data/input matrix (ignored, pass null)
- y_
-
the training/full response vector (e.g., full y)
Attributes
- See also
-
faculty.washington.edu/dbp/s519/PDFs/13-overheads-2020.pdf
- Definition Classes
- Inherited from:
- ARMA
Train/fit an ARMA
model to the times-series data in vector y_. Estimate the coefficient vector b for a (p, q)-th order Auto-Regressive ARMA(p, q) model. Uses a nonlinear optimizer (e.g., LBFGS_B) to determine the coefficients. Residuals are re-estimated during optimization (may lead to instability) NOTE: Requires the error update in predict
to be uncommented.
Train/fit an ARMA
model to the times-series data in vector y_. Estimate the coefficient vector b for a (p, q)-th order Auto-Regressive ARMA(p, q) model. Uses a nonlinear optimizer (e.g., LBFGS_B) to determine the coefficients. Residuals are re-estimated during optimization (may lead to instability) NOTE: Requires the error update in predict
to be uncommented.
Value parameters
- x_null
-
the data/input matrix (ignored, pass null)
- y_
-
the training/full response vector (e.g., full y)
Attributes
- Inherited from:
- ARMA
Train and test the forecasting model y_ = f(y-past) + e and report its QoF and plot its predictions. Return the predictions and QoF.
Train and test the forecasting model y_ = f(y-past) + e and report its QoF and plot its predictions. Return the predictions and QoF.
Value parameters
- y_
-
the training/full response/output vector (defaults to full y)
- yy
-
the testing/full response/output vector (defaults to full y)
Attributes
- Inherited from:
- Forecaster
Inherited fields
The optional reference to an ontological concept
The name for the model (or modeling technique).