AR_Star

scalation.modeling.forecasting.multivar.AR_Star
See theAR_Star companion object
class AR_Star(y: MatrixD, hh: Int, fname: Array[String], tRng: Range, hparam: HyperParameter) extends Diagnoser, ForecastTensor

The AR_Star object is used to make an array of Auto-Regressive models, e.g., one for each variable in a multi-variate time series.

Value parameters

fname

the feature/variable names

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/output matrix (multi-variate time series data)

Attributes

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

Members list

Value members

Concrete methods

For each model, forecast values for all y_.dim time points and all horizons (1 through hh-steps ahead). Record these in the FORECAST TENSOR yf.

For each model, forecast values for all y_.dim time points and all horizons (1 through hh-steps ahead). Record these in the FORECAST TENSOR yf.

Value parameters

y_

the actual values to use in making forecasts

Attributes

def rollValidate(rc: Int, growing: Boolean): TensorD

For each model, 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 --> ] Record the forecasted values in the FORECAST TENSOR yf.

For each model, 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 --> ] Record the forecasted values in the FORECAST TENSOR yf.

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

def trainNtest(y_: MatrixD)(yy: MatrixD): Unit

Train and test each forecasting model y_ = f(y-past) + e and report its QoF and plot its predictions.

Train and test each forecasting model y_ = f(y-past) + e and report its QoF and plot its predictions.

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 methods

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: VectorD, up: VectorD, alpha: 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. 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
def diagnose_wis(y: VectorD, yp: VectorD, low: MatrixD, up: MatrixD, alphas: Array[Double]): Double

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

Return the the y-transformation.

Return the the y-transformation.

Attributes

Inherited from:
Fit
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
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
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
def rSq0_: Double

Attributes

Inherited from:
FitM
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 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 (model, error)

Attributes

Inherited from:
Fit
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 show_interval_forecasts(yy: VectorD, yfh: VectorD, low: VectorD, up: VectorD, qof_all: VectorD, h: Int): Unit

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

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

Concrete fields

val modelName: String

Inherited fields

protected var skip: Int

Attributes

Inherited from:
Diagnoser