split_data_counterfactual: Split Data into Training and Application Datasets

View source: R/modelling.R

split_data_counterfactualR Documentation

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)

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")

Value

A list with two elements:

train

Data outside the application period.

apply

Data within the application period.

Examples

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)

ubair documentation built on April 12, 2025, 2:12 a.m.