library(dplyr)
# DATA ----
m750 <- m4_monthly %>% dplyr::filter(id == "M750")
# RESAMPLE SPEC ----
resample_spec <- time_series_cv(data = m750,
initial = "6 years",
assess = "24 months",
skip = "24 months",
cumulative = FALSE,
slice_limit = 3)
resample_spec
# VISUALIZE CV PLAN ----
# Select date and value columns from the tscv diagnostic tool
resample_spec %>% tk_time_series_cv_plan()
# Plot the date and value columns to see the CV Plan
resample_spec %>%
plot_time_series_cv_plan(date, value, .interactive = FALSE)
# PANEL DATA / TIME SERIES GROUPS ----
# - Time Series Groups are processed using an *ungrouped* data set
# - The data has sliding windows applied starting with the beginning of the series
# - The seven groups of weekly time series are
# processed together for dimensions
walmart_tscv <- walmart_sales_weekly %>%
time_series_cv(
date_var = Date,
initial = "12 months",
assess = "3 months",
skip = "3 months",
slice_limit = 4
)
walmart_tscv
walmart_tscv %>%
plot_time_series_cv_plan(Date, Weekly_Sales, .interactive = FALSE)
Run the code above in your browser using DataLab