Learn R Programming

ubair (version 1.1.1)

split_data_counterfactual: Split Data into Training and Application Datasets

Description

Splits prepared data into training and application datasets based on specified date ranges for a business-as-usual scenario. Data before application_start and after application_end is used as training data, while data within the date range is used for application.

Usage

split_data_counterfactual(dt_prepared, application_start, application_end)

Value

A list with two elements:

train

Data outside the application period.

apply

Data within the application period.

Arguments

dt_prepared

The prepared data table.

application_start

The start date(date object) for the application period of the business-as-usual simulation. This coincides with the start of the reference window. Can be created by e.g. lubridate::ymd("20191201")

application_end

The end date(date object) for the application period of the business-as-usual simulation. This coincides with the end of the effect window. Can be created by e.g. lubridate::ymd("20191201")

Examples

Run this code
dt_prepared <- data.table::data.table(
  date = as.Date(c("2023-01-01", "2023-01-05", "2023-01-10")),
  value = c(50, 60, 70)
)
result <- split_data_counterfactual(
  dt_prepared,
  application_start = as.Date("2023-01-03"),
  application_end = as.Date("2023-01-08")
)
print(result$train)
print(result$apply)

Run the code above in your browser using DataLab