| slice_test | R Documentation |
Extract test observations from a complete time series data set according to a
split plan created by make_split().
slice_test(main_frame, split_frame, context)
main_frame |
A |
split_frame |
A |
context |
A named |
slice_test() uses the row positions stored in the test
list-column of split_frame to extract the corresponding observations
from main_frame. The function is designed for rolling-origin time
series cross-validation workflows.
The returned data has the same columns as main_frame, plus a
split column identifying the train-test split. If main_frame
contains multiple time series, slicing is performed separately for each
series using the series identifier supplied in context.
When make_split() was called with n_lag > 0, the test data may
include lagged observations before the forecast horizon.
A tibble containing the sliced test data. It contains the same columns
as main_frame, plus a split column.
Other time series cross-validation:
make_future(),
make_split(),
make_tsibble(),
slice_train(),
split_index()
library(dplyr)
context <- list(
series_id = "series",
value_id = "value",
index_id = "index"
)
main_frame <- M4_monthly_data |>
filter(series == "M23100")
split_frame <- make_split(
main_frame = main_frame,
context = context,
type = "first",
value = 120,
n_ahead = 18,
n_skip = 17,
n_lag = 0,
mode = "stretch",
exceed = FALSE
)
test_frame <- slice_test(
main_frame = main_frame,
split_frame = split_frame,
context = context
)
test_frame
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.