The VAR
class provides multi-variate time series analysis capabilities for VAR models. VAR models are similar to ARX
models, except that the exogenous variables are treated as endogenous variables and are themselves forecasted. Potentially having more up-to-date forecasted values feeding into multi-horizon forecasting can improve accuracy, but may also lead to compounding of forecast errors. Given multi-variate time series data stored in matrix y, its next value y_t = combination of last p vector values of y.
y_t = b dot x_t + e_t
where y_t is the value of y at time t and e_t is the residual/error term.
Value parameters
- bakcast
-
whether a backcasted value is prepended to the time series (defaults to false)
- fname
-
the feature/variable names
- hh
-
the maximum forecasting horizon (h = 1 to hh)
- hparam
-
the hyper-parameters (defaults to
MakeMatrix4TS.hp
) - tRng
-
the time range, if relevant (time index may suffice)
- x
-
the input lagged time series data
- y
-
the response/output matrix (multi-variate time series data)
Attributes
Members list
Value members
Concrete methods
Diagnose the quality of the model for each variable.
Diagnose the quality of the model for each variable.
Value parameters
- yp
-
the matrix of predicted values
- yy
-
the matrix of actual values
Attributes
Forecast values for all y_.dim time points and all horizons (1 through hh-steps ahead). Record these in the FORECAST TENSOR yf, where
Forecast values for all y_.dim time points and all horizons (1 through hh-steps ahead). Record these in the FORECAST TENSOR yf, where
yf(t, h) = h-steps ahead forecast for y_t
Value parameters
- y_
-
the actual values to use in making forecasts
Attributes
Forecast values for all y_.dim time points at horizon h (h-steps ahead). Assign into FORECAST TENSOR and return the h-steps ahead forecast. Note, yf(t, h, j) if the forecast to time t, horizon h, variable j Note, predictAll
provides predictions for h = 1.
Forecast values for all y_.dim time points at horizon h (h-steps ahead). Assign into FORECAST TENSOR and return the h-steps ahead forecast. Note, yf(t, h, j) if the forecast to time t, horizon h, variable j 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.
Forge a new vector from the first spec values of x, the last p-h+1 values of x (past values), values 1 to h-1 from the forecasts, and available values from exogenous variables.
Forge a new vector from the first spec values of x, the last p-h+1 values of x (past values), values 1 to h-1 from the forecasts, and available values from exogenous variables.
Value parameters
- h
-
the forecasting horizon, number of steps ahead to produce forecasts
- xx
-
the t-th row of the input matrix (lagged actual values)
- yy
-
the t-th row of the forecast tensor (forecasted future values)
Attributes
Return the feature/variable names.
Return the feature/variable names.
Attributes
Get the data/input matrix built from lagged y vector values.
Get the data/input matrix built from lagged y vector values.
Attributes
Return the used response vector y (first colum in matrix).
Return the used response vector y (first colum in matrix).
Attributes
Return the used response matrix y. Mainly for derived classes where y is transformed.
Return the used response matrix y. Mainly for derived classes where y is transformed.
Attributes
- Definition Classes
Return the hyper-parameters.
Return the hyper-parameters.
Attributes
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 = b_0 + b_1 y_t-1 + b_2 y_t-2 + ... + b_p y_t-p = b dot x_t
FIX - parameter order is in conflict with AR models.
Value parameters
- t
-
the time point being predicted
- y_
-
the actual values to use in making predictions (ignored)
Attributes
Predict the value of y = f(z) by evaluating the model equation. Single output models return Double
, while multi-output models return VectorD
.
Predict the value of y = f(z) by evaluating the model equation. Single output models return Double
, while multi-output models return VectorD
.
Value parameters
- z
-
the new vector to predict
Attributes
Predict all values corresponding to the given time series vector y_. Update FORECAST TENSOR yf and return PREDICTION MATRIX yp as second (1) column of yf with last value removed. Note, yf(t, h, j) if the forecast to time t, horizon h, variable j
Predict all values corresponding to the given time series vector y_. Update FORECAST TENSOR yf and return PREDICTION MATRIX yp as second (1) column of yf with last value removed. Note, yf(t, h, j) if the forecast to time t, horizon h, variable j
Value parameters
- y_
-
the actual time series values to use in making predictions
Attributes
- See also
-
forecastAll
to forecast beyond horizon h = 1.Forecaster.predictAll
for template implementation for vectors
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_
-
the data/input matrix (ignored, pass null)
- y_
-
the actual testing/full response/output matrix
Attributes
Test/evaluate the model's Quality of Fit (QoF) and return the predictions and QoF vectors. This may include the importance of its parameters (e.g., if 0 is in a parameter's confidence interval, it is a candidate for removal from the model). Extending traits and classess should implement various diagnostics for the test and full (training + test) datasets.
Test/evaluate the model's Quality of Fit (QoF) and return the predictions and QoF vectors. This may include the importance of its parameters (e.g., if 0 is in a parameter's confidence interval, it is a candidate for removal from the model). Extending traits and classess should implement various diagnostics for the test and full (training + test) datasets.
Value parameters
- x_
-
the testiing/full data/input matrix (impl. classes may default to x)
- y_
-
the testiing/full response/output vector (impl. classes may default to y)
Attributes
Train/fit an VAR
model to the times-series data in vector y_. Estimate the coefficient matrix bb for a p,q-th order VAR(p, q) model. Uses OLS Matrix Factorization to determine the coefficients, i.e., the bb matrix.
Train/fit an VAR
model to the times-series data in vector y_. Estimate the coefficient matrix bb for a p,q-th order VAR(p, q) model. Uses OLS Matrix Factorization to determine the coefficients, i.e., the bb matrix.
Value parameters
- x_
-
the data/input matrix (e.g., full x)
- y_
-
the training/full response matrix (e.g., full y)
Attributes
Train the model 'y_ = f(x_) + e' on a given dataset, by optimizing the model parameters in order to minimize error '||e||' or maximize log-likelihood 'll'.
Train the model 'y_ = f(x_) + e' on a given dataset, by optimizing the model parameters in order to minimize error '||e||' or maximize log-likelihood 'll'.
Value parameters
- x_
-
the training/full data/input matrix (impl. classes may default to x)
- y_
-
the training/full response/output vector (impl. classes may default to y)
Attributes
Train and test the forecasting model y_ = f(y-past) + e and report its QoF and plot its predictions. Return the predictions and QoF. NOTE: must use trainNtest_x
when an x matrix is used, such as in ARY
.
Train and test the forecasting model y_ = f(y-past) + e and report its QoF and plot its predictions. Return the predictions and QoF. NOTE: must use trainNtest_x
when an x matrix is used, such as in ARY
.
Value parameters
- x_
-
the training/full data/input matrix (defaults to full x)
- xx
-
the testing/full data/input matrix (defaults to full x)
- y_
-
the training/full response/output vector (defaults to full y)
- yy
-
the testing/full response/output vector (defaults to full y)
Attributes
Inherited methods
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 TENSOR
- yy
-
the actual response/output matrix over all horizons
Attributes
- Inherited from:
- ForecastTensor
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)
- y_
-
the actual multi-variate time series matrix to use in making forecasts
- yf
-
the entire FORECAST TENSOR
Attributes
- Inherited from:
- ForecastTensor
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
Return the diagonalized version of the forecst tensor, i.e., for each of the j-th forecast matrices 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.
Return the diagonalized version of the forecst tensor, i.e., for each of the j-th forecast matrices 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.
Value parameters
- yf
-
the current forecast tensor
Attributes
- Inherited from:
- ForecastTensor
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
Return the the y-transformation.
Return the help string that describes the Quality of Fit (QoF) measures provided by the Fit
trait. Override to correspond to fitLabel.
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 the full FORECAST TENSOR where (for each sheet j) 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 TENSOR where (for each sheet j) 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 multi-variate times values to use in making forecasts
Attributes
- Inherited from:
- ForecastTensor
Models need to provide a means for updating the Degrees of Freedom (DF). Note: Degrees of Freedom are mainly relevant for full and train, not test.
Models need to provide a means for updating the Degrees of Freedom (DF). Note: Degrees of Freedom are mainly relevant for full and train, not test.
Value parameters
- size
-
the size of dataset (full, train, or test sets)
Attributes
- Inherited from:
- Diagnoser
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
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
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 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 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
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
Inherited fields
The optional reference to an ontological concept
The name for the model (or modeling technique).