Forecaster

scalation.modeling.forecasting_old.Forecaster
See theForecaster companion object
trait Forecaster(y: VectorD, tt: VectorD, hparam: HyperParameter) extends Model

The Forecaster trait provides a common framework for several forecasters. Note, the train method must be called first followed by test.

Value parameters

hparam

the hyper-parameters for models extending this trait

tt

the time vector, if relevant (index as time may suffice)

y

the response vector (time series data)

Attributes

Companion
object
Graph
Supertypes
trait Model
class Object
trait Matchable
class Any
Known subtypes
class AR
class AR1MA
class ARIMA
class ARMA
class NullModel
class QuadSpline
class RandomWalk
class TrendModel
Show all

Members list

Value members

Abstract methods

def forecast(t: Int, yf: MatrixD, y_: VectorD, h: Int): VectorD

Produce a vector of size h, of 1 through h-steps ahead forecasts for the model. forecast the following time points: t+1, ..., t-1+h. Note, must create the yf matrix before calling the forecast method. Intended to work with rolling validation (analog of predict method)

Produce a vector of size h, of 1 through h-steps ahead forecasts for the model. forecast the following time points: t+1, ..., t-1+h. Note, must create the yf matrix before calling the forecast method. Intended to work with rolling validation (analog of predict method)

Value parameters

h

the forecasting horizon, number of steps ahead to produce forecasts

t

the time point from which to make forecasts

y_

the actual values to use in making predictions

yf

the forecast matrix (time x horizons)

Attributes

def forecastAt(yf: MatrixD, y_: VectorD, h: Int): VectorD

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

yf

the forecast matrix (time x horizons)

Attributes

See also

forecastAll method in Forecaster trait.

def predict(t: Int, y_: VectorD): Double

Predict a value for y_t+1 using the 1-step ahead forecast. y_t+1 = f (y_t, ...) + e_t+1

Predict a value for y_t+1 using the 1-step ahead forecast. y_t+1 = f (y_t, ...) + e_t+1

Value parameters

t

the time point from which to make prediction

y_

the actual values to use in making predictions

Attributes

def testF(h: Int, y_: VectorD): (VectorD, VectorD, VectorD)

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

def train(x_null: MatrixD, y_: VectorD): Unit

Given a time series y_, train the forecasting function y_ = f(lags (y_)) + e, where f(lags (y_)) is a function of the lagged values of y_, by fitting its parameters.

Given a time series y_, train the forecasting function y_ = f(lags (y_)) + e, where f(lags (y_)) is a function of the lagged values of y_, by fitting its parameters.

Value parameters

x_null

the data/input matrix (ignored, pass null)

y_

the testing/full response/output vector (e.g., full y)

Attributes

Concrete methods

def cap: Int

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

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

As seen from class WeightedMovingAverage, the missing signatures are as follows. For convenience, these are usable as stub implementations.

As seen from class WeightedMovingAverage, the missing signatures are as follows. For convenience, these are usable as stub implementations.

Attributes

def forecastAll(y_: VectorD, h: Int): MatrixD

Forecast values for all y_.dim time points and all horizons (1 through h-steps ahead). Record these in the FORECAST MATRIX yf, where yf(t, k) = k-steps ahead forecast for y_t Note, column 0, yf(?, 0), is set to y (the actual time series values). last column, yf(?, h+1), is set to t (the time values, for reference). Forecast recursively down diagonals in the yf forecast matrix. The top right and bottom left triangles in yf matrix are not forecastable. FIX - merge the forecast matrices used by predictAll and forecastAll.

Forecast values for all y_.dim time points and all horizons (1 through h-steps ahead). Record these in the FORECAST MATRIX yf, where yf(t, k) = k-steps ahead forecast for y_t Note, column 0, yf(?, 0), is set to y (the actual time series values). last column, yf(?, h+1), is set to t (the time values, for reference). Forecast recursively down diagonals in the yf forecast matrix. The top right and bottom left triangles in yf matrix are not forecastable. FIX - merge the forecast matrices used by predictAll and forecastAll.

Value parameters

h

the maximum forecasting horizon, number of steps ahead to produce forecasts

y_

the actual values to use in making forecasts

Attributes

def forecastAtI(y_: VectorD, yfh: VectorD, h: Int, p: Double): (VectorD, VectorD)

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

def forwardSel(cols: Set[Int], idx_q: Int): (Int, Forecaster)

Perform forward selection to find the most predictive variable to add the existing model, returning the variable to add and the new model. May be called repeatedly. Note, all lags up and including 'p|q' define the model.

Perform forward selection to find the most predictive variable to add the existing model, returning the variable to add and the new model. May be called repeatedly. Note, all lags up and including 'p|q' define the model.

Value parameters

cols

the lags/columns currently included in the existing model (currently ignored)

idx_q

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

Attributes

See also

Fit for index of QoF measures.

def forwardSelAll(idx_q: Int, cross: Boolean): (Set[Int], MatrixD)

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

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

Value parameters

cross

whether to include the cross-validation QoF measure (currently ignored)

idx_q

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

Attributes

See also

Fit for index of QoF measures.

def getFname: Array[String]

Return the feature/variable names. Override for models like SARIMAX.

Return the feature/variable names. Override for models like SARIMAX.

Attributes

def getX: MatrixD

Return the used data matrix x. Mainly for derived classes where x is expanded from the given columns in x_, e.g., SymbolicRegression.quadratic adds squared columns.

Return the used data matrix x. Mainly for derived classes where x is expanded from the given columns in x_, e.g., SymbolicRegression.quadratic adds squared columns.

Attributes

def getY: VectorD

Return the used response vector y. Used by derived classes where y may be transformed, e.g., ARX.

Return the used response vector y. Used by derived classes where y may be transformed, e.g., ARX.

Attributes

def getYf: MatrixD

Return the FORECAST MATRIX yf (initially allocated in predictAll method).

Return the FORECAST MATRIX yf (initially allocated in predictAll method).

Attributes

def getYp: VectorD

Return the prediction vector yp.

Return the prediction vector yp.

Attributes

Return the hyper-parameters.

Return the hyper-parameters.

Attributes

def makeForecastMatrix(y_: VectorD, yp_: VectorD, h: Int): MatrixD

Make the full FORECAST MATRIX from the prediction forecast matrix (built by prodictAll). Has has more columns and a few more rows and copies all contents from the prediction forecast matrix.

Make the full FORECAST MATRIX from the prediction forecast matrix (built by prodictAll). Has has more columns and a few more rows and copies all contents from the prediction forecast matrix.

Value parameters

h

the maximum forecasting horizon, number of steps ahead to produce forecasts

y_

the actual values to use in making forecasts

yp_

the predicted values (h=1) to use in making forecasts

Attributes

def nparams: Int

Return the vector of parameter/coefficient values (they are model specific). Override for models with parameters.

Return the vector of parameter/coefficient values (they are model specific). Override for models with parameters.

Attributes

def predict(z: VectorD): Double

The standard signature for prediction does not apply to time series.

The standard signature for prediction does not apply to time series.

Attributes

Predict all values corresponding to the given time series vector y_. Create 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_. Create FORECAST MATRIX yf and return PREDICTION VECTOR yp as second (1) column of yf with last value removed.

Value parameters

h

the forecasting horizon, number of steps ahead to produce forecasts

y_

the actual time series values to use in making predictions

Attributes

See also

forecastAll to forecast beyond horizon h = 1.

Return the vector of residuals/errors.

Return the vector of residuals/errors.

Attributes

def test(x_null: MatrixD, y_: VectorD): (VectorD, VectorD)

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

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 methods

def getYY: MatrixD

Return the used response matrix y, if needed.

Return the used response matrix y, if needed.

Attributes

See also

neuralnet.PredictorMV

Inherited from:
Model
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

Inherited fields

var modelConcept: URI

The optional reference to an ontological concept

The optional reference to an ontological concept

Attributes

Inherited from:
Model
var modelName: String

The name for the model (or modeling technique).

The name for the model (or modeling technique).

Attributes

Inherited from:
Model