laggedData: Create Input Matrix and Output Vector for Time Series Prediction
Description
Given a time series vector, produces the input matrix and output
vector for a time series prediction task. The other parameters are
the lags to include and the number of steps ahead to predict.
Usage
laggedData(x, lags = 0:9, stepsAhead = 1)
Arguments
x
an atomicvector representing a (uniformly
sampled) time series. Any attributes are ignored.
lags
which lags to use for prediction. A vector of
non-negative integral values.
stepsAhead
how many steps ahead to predict. A non-negative
integral value (integer or numeric).
Value
A list with two components:
X
The (length(x) - max(lags) -
stepsAhead) rows by length(lags) columns input
matrix with the same type as x.
y
The output vector with length(x) -
max(lags) - stepsAhead elements. Same type as
x.
Details
The default parameters correspond to predicting one step ahead
(position t+1) using the ten most recent values
(positions t … t-9).