Learn R Programming

tsaux (version 1.0.0)

time_splits: Generate Train/Test Splits

Description

Generates train/test splits given a vector of dates and other options

Usage

time_splits(
  x,
  start = x[1],
  test_length = 1,
  by = test_length,
  window_size = NULL,
  calendar_end = NULL,
  complete_index = TRUE,
  ...
)

Value

A list with each slot having the training dates and test dates

Arguments

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 calendar_eow, applied to x. This should be greater in frequency than the underlying frequency of x (i.e. do not use calendar_eow on monthly indices). This overwrites the use of window_size.

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.

Author

Alexios Galanos