PREDICT_MOVING_AVERAGE
Applies a moving-average (MA) model, created by MOVING_AVERAGE, to an input relation.
Moving average models use the errors of previous predictions to make future predictions. More specifically, the user-specified "lag" determines how many previous predictions and errors it takes into account during computation.
Syntax
PREDICT_MOVING_AVERAGE ( 'timeseries‑column'
USING PARAMETERS
model_name = 'model‑name'
[, start = starting‑index]
[, npredictions = npredictions]
[, missing = "imputation‑method" ] )
OVER (ORDER BY 'timestamp‑column')
FROM input‑relation
Note
The following argument, as written, is required and cannot be omitted nor substituted with another type of clause.
OVER (ORDER BY '<span class="code-variable">timestamp‑column</span>')
Arguments
timeseries‑column- The timeseries column used to make the prediction (only the last
qvalues, specified during model creation, are used). timestamp‑column- The timestamp column, with consistent timesteps, used to make the prediction.
input‑relation- The input relation containing the
timeseries‑columnandtimestamp‑column.Note that
input‑relationcannot have missing values in any of theq(set during training) rows precedingstart. To handle missing values, see IMPUTE or Linear interpolation.
Parameters
model_nameName of the model (case-insensitive).
start- INTEGER >q or ≤0, the index (row) of the
input‑relationat which to start the prediction. If omitted, the prediction starts at the end of theinput‑relation.If the
startindex is greater than the number of rowsNintimeseries‑column, then the values betweenNandstartare predicted and used for the prediction.If negative, the
startindex is identified by counting backwards from the end of theinput‑relation.For an
input‑relationof N rows, negative values have a lower limit of either -1000 or -(N-q), whichever is greater.Default: the end of
input‑relation npredictions- INTEGER ≥1, the number of predicted timesteps.
Default: 10
missing- One of the following methods for handling missing values:
-
drop: Missing values are ignored.
-
error: Missing values raise an error.
-
zero: Missing values are replaced with 0.
-
linear_interpolation: Missing values are replaced by linearly-interpolated values based on the nearest valid entries before and after the missing value. If all values before or after a missing value in the prediction range are missing or invalid, interpolation is impossible and the function errors.
Default: linear_interpolation
-
Examples
See Moving-average model example.