VAR

scalation.modeling.forecasting.multivar.VAR
See theVAR companion object
class VAR(x: MatrixD, y: MatrixD, hh: Int, fname: Array[String] = ..., tRng: Range = ..., hparam: HyperParameter = ..., bakcast: Boolean = ...) extends Forecaster_RegV

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 where matrix x holds the input and matrix y holds the output, the next vector value y_t = combination of last p vector values in x.

y_t = bb dot x_t + e_t

where y_t is the value of y at time t, bb is the parameter matrix 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

Companion
object
Graph
Supertypes
trait Model
class Diagnoser
trait Fit
trait FitM
class Object
trait Matchable
class Any
Show all

Members list

Value members

Concrete methods

def forge(xx: VectorD, yy: MatrixD, h: Int): VectorD

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

Inherited methods

inline def PIbounds(yp: VectorD, ihw_: MatrixD): (MatrixD, MatrixD)

Attributes

Inherited from:
Fit
inline def PIbounds(yp: VectorD, ihw: VectorD): (VectorD, VectorD)

Make the PREDICTION INTERVAL (PI) lower and upper bound vectors from the point predictions and the interval half widths.

Make the PREDICTION INTERVAL (PI) lower and upper bound vectors from the point predictions and the interval half widths.

Value parameters

ihw

the vector of interval half widths (one for each prediction)

yp

the vector of point predictions (y-hat)

Attributes

Inherited from:
Fit
def align(tr_size: Int, y: MatrixD): (VectorD, MatrixD)

Align the actual response matrix for comparison with the predicted/forecasted response matrix, returning a time vector and sliced response matrix.

Align the actual response matrix for comparison with the predicted/forecasted response matrix, returning a time vector and sliced response matrix.

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_RegV
def backwardElimAll(first: Int, cross: String)(using qk: Int): (LinkedHashSet[Int], ArrayBuffer[VectorD])

Perform BACKWARD ELIMINATION to find the LEAST predictive features/variables to REMOVE from the full model, returning the features/variables left and the new Quality of Fit (QoF) measures/metrics for all steps.

Perform BACKWARD ELIMINATION to find the LEAST predictive features/variables to REMOVE from the full model, returning the features/variables left and the new Quality of Fit (QoF) measures/metrics for all steps.

Value parameters

cross

indicator to include the cross-validation/validation QoF measure (defaults to "many")

first

first variable to consider for elimination

qk

index of Quality of Fit (QoF) to use for comparing quality

Attributes

See also

Fit for index of QoF measures/metrics.

Inherited from:
Forecaster_RegV
def beamSelAll(cross: String = ..., bk: Int = ...)(using qk: Int): (LinkedHashSet[Int], ArrayBuffer[VectorD])

Perform BEAM SEARCH SELECTION to find a GOOD COMBINATION of predictive features/variables to have in the model, returning the top k sets of features/variables selected and the new Quality of Fit (QoF) measures/metrics for all steps. At each step, iterate over the models in the beam (top k) and create candidates by adding features (phase 1) and then removing (phase 2). From all the candidates, keep the best k and start a new iteration. Stops when there is no improvement in any of top k (or the maximum number of features is reached.

Perform BEAM SEARCH SELECTION to find a GOOD COMBINATION of predictive features/variables to have in the model, returning the top k sets of features/variables selected and the new Quality of Fit (QoF) measures/metrics for all steps. At each step, iterate over the models in the beam (top k) and create candidates by adding features (phase 1) and then removing (phase 2). From all the candidates, keep the best k and start a new iteration. Stops when there is no improvement in any of top k (or the maximum number of features is reached.

Value parameters

bk

the beam width holding the top k models (defaults to 3)

cross

indicator to include the cross-validation/validation QoF measure (defaults to "many")

qk

index of Quality of Fit (QoF) to use for comparing quality

Attributes

See also

Fit for index of QoF measures/metrics.

Inherited from:
Forecaster_RegV
def buildModel(x_cols: MatrixD, fname2: Array[String] = ...): RegressionMV

Build a sub-model that is restricted to the given columns of the data matrix. Must be implemented for models that support feature selection. Otherwise, use @see `NoBuildModel

Build a sub-model that is restricted to the given columns of the data matrix. Must be implemented for models that support feature selection. Otherwise, use @see `NoBuildModel

Value parameters

fname2

the variable/feature names for the new model (defaults to null)

x_cols

the columns that the new model is restricted to

Attributes

Inherited from:
Forecaster_RegV

Convert the underlying Regression Model to a subtype of Forecaster_Reg Forecasting Model.

Convert the underlying Regression Model to a subtype of Forecaster_Reg Forecasting Model.

Value parameters

mod

the model to convert, e.g., the best model after feature selection

Attributes

Inherited from:
Forecaster_RegV
def crossValidate(k: Int, rando: Boolean): Array[Statistic]

Attributes

Inherited from:
Forecaster_RegV
def diagnose(yy: MatrixD, yp: MatrixD): MatrixD

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

Inherited from:
Forecaster_RegV
override def diagnose(y: VectorD, yp: VectorD, w: VectorD = ...): VectorD

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
def diagnoseAll(yy: TensorD, yf: TensorD): Unit

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
def diagnoseAll(y_: MatrixD, yf: TensorD, tRng: Range = ..., sft: Int = ...): Unit

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
def diagnose_(y: VectorD, yp: VectorD, low_up: (VectorD, VectorD), α: Double = ..., w: VectorD = ...): VectorD

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. This method also includes PREDICTION INTERVAL (PI) metrics/measures.

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. This method also includes PREDICTION INTERVAL (PI) metrics/measures.

Value parameters

low_up

the predicted (lower, upper) bounds vectors

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

α

the significance/nominal level of uncertainty (α) (defaults to 0.1, 10%)

Attributes

See also

otexts.com/fpp2/prediction-intervals.html Note: wis should be computed separately as the bounds are matrices.

Inherited from:
Fit
def diagnose_mat(yy: MatrixD, yyp: MatrixD, w: VectorD = ...): MatrixD

Diagnose the health of the model by computing the Quality of Fit (QoF) measures, from the predicted & actual matrix responses (output variable per column). For some models the instances may be weighted.

Diagnose the health of the model by computing the Quality of Fit (QoF) measures, from the predicted & actual matrix responses (output variable per column). For some models the instances may be weighted.

Value parameters

w

the weights on the instances (defaults to null)

yy

the actual response/output matrix to use (test/full)

yyp

the predicted response/output matrix (test/full)

Attributes

See also

Regression_WLS

Inherited from:
Fit
def diagnose_pi(y: VectorD, yp: VectorD, low_up: (MatrixD, MatrixD), α: VectorD = ..., : Int = ...): (VectorD, Int)

Diagnose the health of the model by computing the Quality of Fit (QoF) measures for both POINT PREDICTIONS and PREDICTION INTERVALS.

Diagnose the health of the model by computing the Quality of Fit (QoF) measures for both POINT PREDICTIONS and PREDICTION INTERVALS.

Value parameters

the index for the main significance level out of the vector α

low_up

the predicted (lower, upper) bounds matrices for various α levels (column for each α level)

y

the given time-series (must be aligned with the interval forecast)

yp

the point prediction mean/median

α

the vector of significance levels (defaults to the K = 11 prediction intervals used by the CDC Forecast Hub)

Attributes

Inherited from:
Fit
def diagnose_wis(y: VectorD, yp: VectorD, low_up: (MatrixD, MatrixD), α: VectorD = ...): Double

Diagnose the health of the model by computing the Quality of Fit (QoF) measures, specifically for the weighted interval score that allows using custom α levels.

Diagnose the health of the model by computing the Quality of Fit (QoF) measures, specifically for the weighted interval score that allows using custom α levels.

Value parameters

low_up

the predicted (lower, upper) bounds matrices for various α levels (column for each α level)

y

the given time-series (must be aligned with the interval forecast)

yp

the point prediction mean/median

α

the vector of significance levels (defaults to the K = 11 prediction intervals used by the CDC Forecast Hub)

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
def equation: String

Print the model prediction equation in readable form. Override per model.

Print the model prediction equation in readable form. Override per model.

Attributes

Inherited from:
Model
def equationLaTeX: String

Print the model prediction equation in LaTex form. Override per model.

Print the model prediction equation in LaTex form. Override per model.

Attributes

Inherited from:
Model
override def fit: VectorD

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
Fit -> FitM
Inherited from:
Fit
def forecast(t: Int, y_: MatrixD): MatrixD

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).

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).

Value parameters

t

the time point from which to make forecasts

y_

the actual values to use in making predictions

Attributes

Inherited from:
Forecaster_RegV

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

Inherited from:
Forecaster_RegV
def forecastAt(h: Int, y_: MatrixD = ...): MatrixD

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 in Forecaster trait.

Inherited from:
Forecaster_RegV
def forwardSelAll(cross: String)(using qk: Int): (LinkedHashSet[Int], ArrayBuffer[VectorD])

Perform FORWARD SELECTION to find the MOST predictive features/variables to ADD into the model, returning the features/variables added and the new Quality of Fit (QoF) measures/metrics for all steps.

Perform FORWARD SELECTION to find the MOST predictive features/variables to ADD into the model, returning the features/variables added and the new Quality of Fit (QoF) measures/metrics for all steps.

Value parameters

cross

indicator to include the cross-validation/validation QoF measure (defaults to "many")

qk

index of Quality of Fit (QoF) to use for comparing quality

Attributes

See also

Fit for index of QoF measures/metrics.

Inherited from:
Forecaster_RegV

Return the best model found from feature selection.

Return the best model found from feature selection.

Attributes

Inherited from:
Forecaster_RegV
def getFname: Array[String]

Return the feature/variable names.

Return the feature/variable names.

Attributes

Inherited from:
Forecaster_RegV
def getX: MatrixD

Get the data/input matrix built from lagged y vector (and optionally xe) values.

Get the data/input matrix built from lagged y vector (and optionally xe) values.

Attributes

Inherited from:
Forecaster_RegV
def getXy: MatrixD

Return the data matrix x concatenated with response vector y.

Return the data matrix x concatenated with response vector y.

Attributes

Inherited from:
Model
def getY: VectorD

Return the used response vector y (first colum in matrix).

Return the used response vector y (first colum in matrix).

Attributes

Inherited from:
Forecaster_RegV

Return the y-transformation.

Return the y-transformation.

Attributes

Inherited from:
Fit
override def getYY: MatrixD

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
Inherited from:
Forecaster_RegV
def getYf: TensorD

Return the used FORECAST TENSOR yf.

Return the used FORECAST TENSOR yf.

Attributes

Inherited from:
Forecaster_RegV
override def help: String

Return the help string that describes the Quality of Fit (QoF) measures provided by the Fit trait. Override to correspond to fitLabel.

Return the help string that describes the Quality of Fit (QoF) measures provided by the Fit trait. Override to correspond to fitLabel.

Attributes

Definition Classes
Fit -> FitM
Inherited from:
Fit

Return the hyper-parameters.

Return the hyper-parameters.

Attributes

Inherited from:
Forecaster_RegV
override def inSample_Test(skip: Int = ..., showYf: Boolean = ...): (VectorD, VectorD)

Perform In-Sample Testing, i.e., train and test on the full data set. Return the prediction and the Quality of Fit.

Perform In-Sample Testing, i.e., train and test on the full data set. Return the prediction and the Quality of Fit.

Value parameters

showYf

whether to show the forecast matrix FIX - copied from Forecaster change it to work for VAR, VARX

skip

the number of initial time points to skip (due to insufficient past)

Attributes

Definition Classes
Inherited from:
Forecaster_RegV
def ll(ms: Double = ..., s2: Double = ..., m2: Int = ...): Double

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
def makeForecastTensor(y_: MatrixD = ..., hh_: Int = ...): TensorD

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
def mod_resetDF(size: Int): Unit

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
inline def modelName: String

Get the model name.

Get the model name.

Attributes

Inherited from:
Model
inline def mse_: Double

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 parameters.

Return the parameters.

Attributes

Inherited from:
Forecaster_RegV
def predict(z: VectorD): Double | VectorD

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

Inherited from:
Forecaster_RegV
def predict(t: Int, y_: MatrixD): VectorD

Predict a value for y_t using the 1-step ahead forecast.

Predict a value for y_t using the 1-step ahead forecast.

Value parameters

t

the time point being predicted

y_

the actual values to use in making predictions FIX -- Forecaster_Reg uses x(t) while x(t-1) is used here

Attributes

See also

modeling.rectify define in Predictor.scala

Inherited from:
Forecaster_RegV

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

Inherited from:
Forecaster_RegV
def predictInt(x_: MatrixD, df_: Double = ..., α: Double = ...): VectorD

Produce a PREDICTION INTERVAL half width for each prediction yp (y-hat).

Produce a PREDICTION INTERVAL half width for each prediction yp (y-hat).

Value parameters

df_

the error/residual degrees of freedom

x_

the testing/full data/input matrix

α

the significance level α = .1 for TWO TAILS: left tail .05 | 1 - α = .90 | .05 right tail e.g., for AutoMPG, t_crit (385, 0.90) = 1.6488210657096942 t_crit (385, 0.95) = 1.966

Attributes

See also

predictCInt in Predictor

stats.stackexchange.com/questions/585660/what-is-the-formula-for-prediction-interval-in-multivariate-case

Inherited from:
Fit
def predictInt_(x_: MatrixD, df_: Double = ..., α: VectorD = ...): MatrixD

Produce a PREDICTION INTERVAL half width for each prediction yp (y-hat) and each significance level.

Produce a PREDICTION INTERVAL half width for each prediction yp (y-hat) and each significance level.

Value parameters

df_

the error/residual degrees of freedom

x_

the testing/full data/input matrix

α

the significance levels to be used (defaults to Fit.α_)

Attributes

Inherited from:
Fit
def qof2Stat(qof: VectorD): Array[Statistic]

Convert QoF results into an array (of size 1) of Statistic for compatibility with the crossValidate method.

Convert QoF results into an array (of size 1) of Statistic for compatibility with the crossValidate method.

Value parameters

qof

the Quality of Fit (QoF) results

Attributes

Inherited from:
Model
inline def rSq0_: Double

Attributes

Inherited from:
FitM
inline def rSq_: Double

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
def report(ftMat: MatrixD): String

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
def report(ftVec: VectorD): String

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
def resetBest(): Unit

Reset the best-step to default

Reset the best-step to default

Attributes

Inherited from:
Forecaster_RegV
def resetDF(df_update: (Double, Double)): Unit

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 (regression/model, error)

Attributes

Inherited from:
Fit
def rollValidate(rc: Int = ..., growing: Boolean = ...): TensorD

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 TENSOR.

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 TENSOR.

Value parameters

growing

whether the training grows as it roll or kepps a fixed size FIX - copied from Forecaster change it to work for VAR, VARX

rc

the retraining cycle (number of forecasts until retraining occurs)

Attributes

Inherited from:
Forecaster_RegV
def screen(xy: MatrixD, thr1: Double = ..., thr2: Double = ...)(dep: MatrixD = ...): (MatrixD, VectorI)

Screen the x-columns of matrix xy based on the two thresholds, returning the reduced matrix and the column indices/predictor variables selected.

Screen the x-columns of matrix xy based on the two thresholds, returning the reduced matrix and the column indices/predictor variables selected.

Value parameters

dep

the variable/column dependency measure (defaults to correlation)

thr1

the threshold used to compare the predictor x-columns to the y-column only want variables above some minimal dependency level

thr2

the threshold used to compare the predictor x-columns with each other only want variables below some cut-off dependency/collinearity level

xy

the [ x, y ] combined data-response matrix

Attributes

Inherited from:
Model
def selectFeatures(tech: SelectionTech, cross: String = ..., first: Int = ..., swap: Boolean = ...)(using qk: Int): (LinkedHashSet[Int], ArrayBuffer[VectorD])

Perform feature selection to find the most predictive features/variables to have in the model, returning the features/variables added and the new Quality of Fit (QoF) measures/metrics for all steps.

Perform feature selection to find the most predictive features/variables to have in the model, returning the features/variables added and the new Quality of Fit (QoF) measures/metrics for all steps.

Value parameters

cross

indicator to include the cross-validation/validation QoF measure (defaults to "many")

first

first variable to consider for elimination (default (1) assume intercept x_0 will be in any model)

qk

index of Quality of Fit (QoF) to use for comparing quality

swap

whether to allow a swap step (swap out a feature for a new feature in one step)

tech

the feature selection technique to apply

Attributes

See also

Fit for index of QoF measures/metrics.

Inherited from:
FeatureSelection
def setSkip(skip_: Int): Unit

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
def showQoF(qof: VectorD): Unit

Show the QoF metrics/measures in vector qof.

Show the QoF metrics/measures in vector qof.

Value parameters

qof

the QoF metrics (e.g., for point and interval predictions/forecasts)

Attributes

Inherited from:
Fit
inline def sse_: Double

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
def ssef(y: VectorD, yp: VectorD): Double

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
def stepwiseSelAll(cross: String, swap: Boolean)(using qk: Int): (LinkedHashSet[Int], ArrayBuffer[VectorD])

Perform STEPWISE SELECTION to find a GOOD COMBINATION of predictive features/variables to have in the model, returning the features/variables selected and the new Quality of Fit (QoF) measures/metrics for all steps. At each step, it calls forward and backward and takes the best of the two actions. Stops when neither action yields improvement.

Perform STEPWISE SELECTION to find a GOOD COMBINATION of predictive features/variables to have in the model, returning the features/variables selected and the new Quality of Fit (QoF) measures/metrics for all steps. At each step, it calls forward and backward and takes the best of the two actions. Stops when neither action yields improvement.

Value parameters

cross

indicator to include the cross-validation/validation QoF measure (defaults to "many")

qk

index of Quality of Fit (QoF) to use for comparing quality

swap

whether to allow a swap step (swap out a feature for a new feature in one step)

Attributes

See also

Fit for index of QoF measures/metrics.

Inherited from:
Forecaster_RegV
override def summary(x_: MatrixD = ..., fname: Array[String] = ..., b: VectorD = ..., vifs: VectorD = ...): String

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
Fit -> FitM
Inherited from:
Fit
inline def taskType: TaskType

Get the type of the task performed by model.

Get the type of the task performed by model.

Attributes

Inherited from:
Model
def test(x_: MatrixD, y_: VectorD): (VectorD, VectorD)

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 classes 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 classes should implement various diagnostics for the test and full (training + test) datasets.

Value parameters

x_

the testing/full data/input matrix (impl. classes may default to x)

y_

the testing/full response/output vector (impl. classes may default to y)

Attributes

Inherited from:
Forecaster_RegV
def test(x_: MatrixD, y_: MatrixD): (MatrixD, MatrixD)

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

Inherited from:
Forecaster_RegV
def train(x_: MatrixD, y_: VectorD): Unit

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

Inherited from:
Forecaster_RegV
def train(x_: MatrixD, y_: MatrixD): Unit

Train/fit an Forecaster_RegV model to the times-series data y_ = f(x). Estimate the coefficient matrix bb for a Forecaster_RegV model. Uses OLS Matrix Factorization to determine the coefficients, i.e., the bb matrix.

Train/fit an Forecaster_RegV model to the times-series data y_ = f(x). Estimate the coefficient matrix bb for a Forecaster_RegV 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

Inherited from:
Forecaster_RegV
def trainNtest_x(x_: MatrixD = ..., y_: MatrixD = ...)(xx: MatrixD = ..., yy: MatrixD = ...): (MatrixD, MatrixD)

Train and test the forecasting model y_ = f(x_) + 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 VAR.

Train and test the forecasting model y_ = f(x_) + 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 VAR.

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 from:
Forecaster_RegV
def validate(rando: Boolean = ..., ratio: Double = ...)(idx: IndexedSeq[Int] = ...): (VectorD, VectorD)

Attributes

Inherited from:
Forecaster_RegV

Inherited fields

var modelConcept: URI

The optional reference to an ontological concept

The optional reference to an ontological concept

Attributes

Inherited from:
Model
protected var skip: Int

Attributes

Inherited from:
Diagnoser