ts_windows: Build a lagged-feature table from one or more time series
Description
Converts time series into a data frame suitable for training forecasting
models: each row holds the target y (the value horizon steps ahead) and
the lags preceding values lag1 (most recent) ... lagp. With a list of
series (e.g. from augment_data()), the windows of all series are stacked
and a series column identifies their origin; windows never cross series
boundaries.
Usage
ts_windows(x, lags, horizon = 1L, target = 1L)
Value
A data frame with columns y, the lag columns and (for lists)
series.
Arguments
x
A ts object, numeric vector/matrix, or a list of them.
lags
Number of lags.
horizon
Forecast horizon (1 = one step ahead).
target
For multivariate series: name or index of the target column.
Details
For multivariate series, lags of every component are created
(<name>_lag1, ...) and the target is the column named by target.