class ExpSmoothing extends ForecasterVec with NoFeatureSelectionF
The ExpSmoothing
class provide very basic time series analysis capabilities of
Exponential Smoothing models. ExpSmoothing
models are often used for forecasting.
Given time series data stored in vector 'y', its next value 'y_t = y(t)'
may be predicted based on prior/smoothed values of 'y':
y_t = s_t-1 + α (s_t-1 - s_t-2)
where vector 's' is the smoothed version of vector 'y' and 'α in [0, 1]' is the smoothing parameter. Trend and seasonality can be factored into the model with two additional smoothing parameters 'β' and 'γ', respectively.
- Alphabetic
- By Inheritance
- ExpSmoothing
- NoFeatureSelectionF
- ForecasterVec
- Predictor
- Model
- Fit
- Error
- QoF
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Instance Constructors
- new ExpSmoothing(y_: VectoD, hparam: HyperParameter = ExpSmoothing.hp)
- y_
the input vector (orginal time series data)
- hparam
the hyper-parameters
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- def acF: VectoD
Return the autocorrelation.
Return the autocorrelation. Must call 'train' first.
- Definition Classes
- ForecasterVec
- def analyze(x_: MatriD = null, y_: VectoD = y, x_e: MatriD = null, y_e: VectoD = y): ForecasterVec
Analyze a dataset using this model using ordinary training with the 'train' method.
Analyze a dataset using this model using ordinary training with the 'train' method.
- x_
the training/full the data/input matrix (ignore)
- y_
the training/full the response/output vector
- x_e
the test/full data/input matrix (ignore)
- y_e
the test/full response/output vector
- Definition Classes
- ForecasterVec → Predictor
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native() @HotSpotIntrinsicCandidate()
- def corrMatrix(xx: MatriD): MatriD
Return the correlation matrix for the columns in data matrix 'xx'.
Return the correlation matrix for the columns in data matrix 'xx'.
- xx
the data matrix shose correlation matrix is sought
- Definition Classes
- Predictor
- def diagnose(e: VectoD, yy: VectoD, yp: VectoD, w: VectoD = null, ym_: Double = noDouble): Unit
Diagnose the health of the model by computing the Quality of Fit (QoF) measures, from the error/residual vector and the predicted & actual responses.
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.
- e
the m-dimensional error/residual vector (yy - yp)
- yy
the actual response/output vector to use (test/full)
- yp
the predicted response/output vector (test/full)
- w
the weights on the instances (defaults to null)
- ym_
the mean of the actual response/output vector to use (training/full)
- var e: VectoD
- Attributes
- protected
- Definition Classes
- ForecasterVec
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def eval(y_e: VectoD = y): ForecasterVec
Compute the error (difference between actual and predicted) and useful diagnostics for the dataset.
Compute the error (difference between actual and predicted) and useful diagnostics for the dataset.
- y_e
the test/full actual response/output vector
- Definition Classes
- ForecasterVec
- def eval(x_e: MatriD, y_e: VectoD): ForecasterVec
Compute the error (difference between actual and predicted) and useful diagnostics for the dataset.
Compute the error (difference between actual and predicted) and useful diagnostics for the dataset.
- x_e
the test/full data/input matrix (ignored, pass null)
- y_e
the test/full actual response/output vector
- Definition Classes
- ForecasterVec → Model
- def evalf(y_e: VectoD, yf: VectoD): ForecasterVec
Compute the error (difference between actual and predicted) and useful diagnostics for the dataset.
Compute the error (difference between actual and predicted) and useful diagnostics for the dataset.
- y_e
the test/full actual response/output vector
- yf
the vector of forecasts
- Definition Classes
- ForecasterVec
- def f_(z: Double): String
Format a double value.
- def f_obj(input: VectoD): Double
The objective function to be minimized (sum of squared errors).
The objective function to be minimized (sum of squared errors).
- input
the input vector of 'α', 'β' and 'γ' to be optimized
- def fit: VectoD
Return the Quality of Fit (QoF) measures corresponding to the labels given above in the 'fitLabel' method.
Return the Quality of Fit (QoF) measures corresponding to the labels given above in the 'fitLabel' method. 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.
- def fitLabel: Seq[String]
Return the labels for the Quality of Fit (QoF) measures.
- def fitMap: Map[String, String]
Build a map of quality of fit measures (use of
LinkedHashMap
makes it ordered).Build a map of quality of fit measures (use of
LinkedHashMap
makes it ordered).- Definition Classes
- QoF
- final def flaw(method: String, message: String): Unit
- Definition Classes
- Error
- def forecast(t: Int = y.dim-1, h: Int = 1): VectoD
Produce a vector of size 'h', of 1 through 'h'-steps ahead forecasts for the model.
Produce a vector of size 'h', of 1 through 'h'-steps ahead forecasts for the model.
- t
the time point from which to make forecasts (defaults to the last time point)
- h
the forecasting horizon, number of steps ahead to produce forecasts
- Definition Classes
- ExpSmoothing → ForecasterVec
- See also
ams.sunysb.edu/~zhu/ams586/Forecasting.pdf
- def forecast(yf: MatriD, t: Int, h: Int): VectoD
Produce a vector of size 'h', of 1 through 'h'-steps ahead forecasts for the model.
Produce a vector of size 'h', of 1 through 'h'-steps ahead forecasts for the model.
forecast the following time points: t, t+1, ..., t-1+h.
Note, invoke 'forecastAll' to create the 'yf' matrix.
- yf
the y-forecast matrix for all time and horizons
- t
the time point from which to make forecasts
- h
the forecasting horizon, number of steps ahead to produce forecasts
- Definition Classes
- ForecasterVec
- def forecastAll(h: Int): MatriD
Forecast values for all time points using 1 through 'h'-steps ahead forecasts.
Forecast values for all time points using 1 through 'h'-steps ahead forecasts. The 'h'-th row of matrix is the horizon 'h' forecast (where 'h = 0' is actual data).
- h
the forecasting horizon, number of steps ahead to produce forecasts, must be > 0
- Definition Classes
- ExpSmoothing → ForecasterVec
- def forecastAll(h: Int, p: Int): MatriD
Forecast values for all time points using 1 through 'h'-steps ahead forecasts.
Forecast values for all time points using 1 through 'h'-steps ahead forecasts. The 'h'-th row of matrix is the horizon 'h' forecast (where 'h = 0' is actual data).
- h
the forecasting horizon, number of steps ahead to produce forecasts, must be > 0
- p
the order of the model (e.g, p in AR, q in MA) or number of values to use in making forecasts, must be > 0
- Definition Classes
- ForecasterVec
- def forecastX(y: VectoD, t: Int, h: Int = 1): Double
Produce h-steps ahead forecast on the testing data during cross validation.
Produce h-steps ahead forecast on the testing data during cross validation. Likely to need overriding.
- y
the current response vector
- t
the time point/index to be forecast
- h
the forecasting horizon, number of steps ahead to produce forecast
- Definition Classes
- ForecasterVec
- def forwardSel(cols: Set[Int], index_q: Int): (Int, ForecasterVec)
- Definition Classes
- NoFeatureSelectionF
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- def getX: MatriD
Return the 'used' data matrix 'x' (for such models, it's null).
Return the 'used' data matrix 'x' (for such models, it's null).
- Definition Classes
- ForecasterVec → Predictor
- def getY: VectoD
Return the 'used' response vector 'y'.
Return the 'used' response vector 'y'. Mainly for derived classes where 'y' is transformed, e.g.,
TranRegression
,Regression4TS
.- Definition Classes
- ForecasterVec → Predictor
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- def help: String
Return the help string that describes the Quality of Fit (QoF) measures provided by the
Fit
class. - def hparameter: HyperParameter
Return the hyper-parameters.
Return the hyper-parameters.
- Definition Classes
- ForecasterVec → Model
- def init(): Unit
Compute initial values of 's', 'b', 'aa' and 'c'.
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def ll(ms: Double = mse0, s2: Double = sig2e, m2: Int = m): Double
The log-likelihood function times -2.
The log-likelihood function times -2. Override as needed.
- ms
raw Mean Squared Error
- s2
MLE estimate of the population variance of the residuals
- Definition Classes
- Fit
- See also
www.stat.cmu.edu/~cshalizi/mreg/15/lectures/06/lecture-06.pdf
www.wiley.com/en-us/Introduction+to+Linear+Regression+Analysis%2C+5th+Edition-p-9780470542811 Section 2.11
- val m: Int
- Attributes
- protected
- Definition Classes
- ForecasterVec
- val ml: Int
- Attributes
- protected
- Definition Classes
- ForecasterVec
- val modelConcept: URI
An optional reference to an ontological concept
An optional reference to an ontological concept
- Definition Classes
- Model
- def modelName: String
Return the model name including current its hyper-parameter.
Return the model name including current its hyper-parameter.
- Definition Classes
- ExpSmoothing → Model
- def mse_: Double
Return the mean of squares for error (sse / df._2).
Return the mean of squares for error (sse / df._2). Must call diagnose first.
- Definition Classes
- Fit
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- def pacF: VectoD
Return the partial autocorrelation.
Return the partial autocorrelation. Must call 'train' first.
- Definition Classes
- ForecasterVec
- var pacf: VectoD
- Attributes
- protected
- Definition Classes
- ForecasterVec
- def parameter: VectoD
Return the parameter vector.
Return the parameter vector.
- Definition Classes
- ExpSmoothing → Model
- def plotFunc(fVec: VectoD, name: String, show: Boolean = true): Unit
Plot a function, e.g., Auto-Correlation Function 'ACF', Partial Auto-Correlation Function 'PACF'.
Plot a function, e.g., Auto-Correlation Function 'ACF', Partial Auto-Correlation Function 'PACF'.
- fVec
the vector given function values
- name
the name of the function
- show
whether to show the fVec values
- Definition Classes
- ForecasterVec
- def plotFunc2(fVec: VectoD, name: String, show: Boolean = true): Unit
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.
- fVec
the vector given function values
- name
the name of the function
- show
whether to show the fVec values
- Definition Classes
- ForecasterVec
- def predict(z: MatriD): VectoD
Predict the value of 'y = f(z)' for each row of matrix 'z'.
Predict the value of 'y = f(z)' for each row of matrix 'z'.
- z
the new matrix to predict
- Definition Classes
- ForecasterVec → Predictor
- def predict(y_null: VectoD = null): Double
Return the horizon 1 forecast beyond the end of the time-series.
Return the horizon 1 forecast beyond the end of the time-series.
- y_null
the actual response/output vector to use (ignored)
- Definition Classes
- ForecasterVec → Predictor
- def predict(z: VectoI): Double
Given a new discrete data/input vector 'z', predict the 'y'-value of 'f(z)'.
Given a new discrete data/input vector 'z', predict the 'y'-value of 'f(z)'.
- z
the vector to use for prediction
- Definition Classes
- Predictor
- def predictAll(): VectoD
Return the vector of predicted values on the training data.
Return the vector of predicted values on the training data.
- Definition Classes
- ExpSmoothing → ForecasterVec
- def predictAllz(): VectoD
Return the vector of centered predicted values on the training data.
Return the vector of centered predicted values on the training data.
- Definition Classes
- ExpSmoothing → ForecasterVec
- var psi: MatriD
- Attributes
- protected
- Definition Classes
- ForecasterVec
- def report: String
Return a basic report on the trained model.
Return a basic report on the trained model.
- Definition Classes
- ForecasterVec → Model
- def resetDF(df_update: PairD): Unit
Reset the degrees of freedom to the new updated values.
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.
- df_update
the updated degrees of freedom (model, error)
- Definition Classes
- Fit
- def residual: VectoD
Return the vector of residuals/errors.
Return the vector of residuals/errors.
- Definition Classes
- ForecasterVec → Predictor
- def setTS(y_: VectoD): Unit
Set/change the internal time series.
Set/change the internal time series. May be used to set the time series to a different time window (typically future when new data become available) in order to produce newer forecast (typically with the new data) without re-training the model for parameters (use existing parameters from previous training).
- y_
the new time series
- var sig2e: Double
- Attributes
- protected
- Definition Classes
- Fit
- def smooth(input: VectoD = VectorD (α, β, γ)): VectoD
Smooth the times series data.
Smooth the times series data.
- input
the input vector of 'α', 'β' and 'γ' to be optimized
- var stats: Stats
- Attributes
- protected
- Definition Classes
- ForecasterVec
- def summary(b: String, modelEq: String): String
Return a detailed summary of the trained model.
Return a detailed summary of the trained model.
- b
the symbol(s) used for the parameters
- modelEq
the model equation as a string
- Definition Classes
- ForecasterVec
- def summary(b: VectoD, stdErr: VectoD, vf: VectoD, show: Boolean = false): String
Produce a summary report with diagnostics for each predictor 'x_j' and the overall quality of fit.
Produce a summary report with diagnostics for each predictor 'x_j' and the overall quality of fit.
- b
the parameters/coefficients for the model
- vf
the Variance Inflation Factors (VIFs)
- show
flag indicating whether to print the summary
- Definition Classes
- Fit
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def test(modelName: String, doPlot: Boolean = true): Unit
Test the model on the full dataset (i.e., train and evaluate on full dataset).
Test the model on the full dataset (i.e., train and evaluate on full dataset).
- modelName
the name of the model being tested
- doPlot
whether to plot the actual vs. predicted response
- Definition Classes
- Predictor
- def toString(): String
- Definition Classes
- AnyRef → Any
- def train(x_null: MatriD, y_: VectoD): ExpSmoothing
Train the
ExpSmoothing
model to times series data, by finding the value for the smoothing parameter 'α', 'β' and 'γ' that minimizes the sum of squared errors (sse).Train the
ExpSmoothing
model to times series data, by finding the value for the smoothing parameter 'α', 'β' and 'γ' that minimizes the sum of squared errors (sse).- x_null
the data/input matrix (ignored)
- y_
the response/output vector (training/full)
- Definition Classes
- ExpSmoothing → ForecasterVec → Model
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- var yf: MatriD
- Attributes
- protected
- Definition Classes
- ForecasterVec
- var z: VectoD
- Attributes
- protected
- Definition Classes
- ForecasterVec
Deprecated Value Members
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable]) @Deprecated
- Deprecated