| ts_data_mv | R Documentation |
Construct a multivariate time-series object used throughout the target-centered multivariate workflow.
ts_data_mv(
data,
y = NULL,
x = NULL,
sw = 1,
variables = NULL,
lags = NULL,
transforms = NULL
)
data |
data.frame or matrix with one column per variable and one row per
time index. It can also be an existing |
y |
Optional character scalar. Name of the target variable. When |
x |
Optional character vector. Names of the auxiliary variables. By
default, all columns except |
sw |
Integer. Temporal width of the representation. Use |
variables |
Optional character vector. Variables to include when
|
lags |
Optional named list with one integer vector per variable. When
omitted, every variable uses all lags from |
transforms |
Optional named list of raw-series transformations applied per variable before the lagged blocks are built. Each entry can be a single transform object or a list of transforms. |
ts_data_mv() follows the same design principle as ts_data() in the
univariate path:
with sw = 1, it stores aligned multivariate observations
with sw > 1, it materializes multivariate lagged windows
This keeps a single data abstraction for both the aligned and the lagged representations.
In aligned mode (sw = 1):
each row is a time instant
each column is one variable
In lagged mode (sw > 1):
each row is a forecasting origin
each variable contributes one lag block
column names follow the pattern var_tk
Optional variables, lags, and transforms let the caller inspect a
specific multivariate feature space while staying inside the ts_data_mv
abstraction.
A ts_data_mv object.
data(tsd)
x1 <- c(tsd$y[-1], tail(tsd$y, 1))
x2 <- stats::filter(tsd$y, rep(1/3, 3), sides = 1)
x2[is.na(x2)] <- tsd$y[is.na(x2)]
mv <- ts_data_mv(
data.frame(y = tsd$y, x1 = x1, x2 = as.numeric(x2)),
y = "y"
)
ts_head(mv, 3)
mv_sw <- ts_data_mv(mv, sw = 5)
ts_head(mv_sw, 3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.