time_splits | R Documentation |
Generates train/test splits given a vector of dates and other options
time_splits(
x,
start = x[1],
test_length = 1,
by = test_length,
window_size = NULL,
calendar_end = NULL,
complete_index = TRUE,
...
)
x |
a vector of timestamps (POSIXct) or dates (Date) in the dataset |
start |
starting date (first estimation/train date) |
test_length |
type of calendar period to split on |
by |
every how many periods to split on |
window_size |
the size of the training set (for moving window). If NULL will use an expanding window. |
calendar_end |
an optional function to use for the period ending split,
such as |
complete_index |
whether to return the full indices for train and test else just the start and end indices. |
... |
any additional parameters passed to the calendar_end function. For example, the “day” argument when using the calendar_eow function. |
A list with each slot having the training dates and test dates
For months, quarters and years this will split into the end date of these. For splitting into mins or hours, x must also have this resolution else will throw an error. Additionally, the strict requirement of regularly spaced time is required (no gaps).
Alexios Galanos
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.