{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"description": "Comparison of different cross-validation and backtesting techniques applied to synthetic time series data",
"data": {
"sequence": {
"start": 1,
"stop": 365,
"step": 1,
"as": "day"
}
},
"transform": [
{
"calculate": "120 + 0.1 * datum.day + 15 * sin(2 * PI * datum.day / (365 / 4)) + sampleNormal(0, 10)",
"as": "value"
}
],
"hconcat": [
{
"title": "K-Fold Cross-Validation",
"transform": [
{
"calculate": "floor((datum.day - 1) / (365 / 5)) + 1",
"as": "fold"
}
],
"mark": "point",
"encoding": {
"x": {
"field": "day",
"type": "quantitative",
"title": "Day"
},
"y": {
"field": "value",
"type": "quantitative",
"title": "Value"
},
"color": {
"field": "fold",
"type": "nominal",
"title": "Fold"
},
"tooltip": [
{
"field": "day",
"type": "quantitative",
"title": "Day"
},
{
"field": "value",
"type": "quantitative",
"title": "Value"
},
{
"field": "fold",
"type": "nominal",
"title": "Fold"
}
]
}
},
{
"title": "Time-Series Cross-Validation",
"transform": [
{
"calculate": "datum.day <= 292 ? ceil(datum.day / 73) : null",
"as": "fold"
}
],
"mark": "point",
"encoding": {
"x": {
"field": "day",
"type": "quantitative",
"title": "Day"
},
"y": {
"field": "value",
"type": "quantitative",
"title": "Value"
},
"color": {
"field": "fold",
"type": "nominal",
"title": "Fold"
},
"tooltip": [
{
"field": "day",
"type": "quantitative",
"title": "Day"
},
{
"field": "value",
"type": "quantitative",
"title": "Value"
},
{
"field": "fold",
"type": "nominal",
"title": "Fold"
}
]
}
},
{
"title": "Rolling Window Backtesting",
"transform": [
{
"calculate": "datum.day >= 51 ? ceil((datum.day - 50) / 73) : null",
"as": "window"
}
],
"mark": "line",
"encoding": {
"x": {
"field": "day",
"type": "quantitative",
"title": "Day"
},
"y": {
"field": "value",
"type": "quantitative",
"title": "Value"
},
"color": {
"field": "window",
"type": "nominal",
"title": "Window"
},
"tooltip": [
{
"field": "day",
"type": "quantitative",
"title": "Day"
},
{
"field": "value",
"type": "quantitative",
"title": "Value"
},
{
"field": "window",
"type": "nominal",
"title": "Window"
}
]
}
},
{
"title": "Expanding Window Backtesting",
"transform": [
{
"calculate": "datum.day <= 292 ? ceil(datum.day / 73) : null",
"as": "window"
}
],
"mark": "line",
"encoding": {
"x": {
"field": "day",
"type": "quantitative",
"title": "Day"
},
"y": {
"field": "value",
"type": "quantitative",
"title": "Value"
},
"color": {
"field": "window",
"type": "nominal",
"title": "Window"
},
"tooltip": [
{
"field": "day",
"type": "quantitative",
"title": "Day"
},
{
"field": "value",
"type": "quantitative",
"title": "Value"
},
{
"field": "window",
"type": "nominal",
"title": "Window"
}
]
}
}
]
}