{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"description": "Time Series Forecasting Types",
"hconcat": [
{
"title": "Univariate Forecast: S&P 500 % Change",
"width": 300,
"height": 200,
"layer": [
{
"data": {
"sequence": {
"start": 0,
"stop": 30,
"step": 1,
"as": "month"
}
},
"transform": [
{
"calculate": "datum.month < 24 ? 'Actual' : 'Forecast'",
"as": "type"
},
{
"calculate": "datum.month <= 24 ? random() * 2 - 1 : datum.month == 24 ? datum.value : random() * 1.5 - 0.75",
"as": "value"
}
],
"mark": {
"type": "line",
"point": true
},
"encoding": {
"x": {
"field": "month",
"type": "quantitative",
"title": "Month"
},
"y": {
"field": "value",
"type": "quantitative",
"title": "% Change"
},
"color": {
"value": "#00497677"
},
"strokeDash": {
"field": "type",
"type": "nominal",
"scale": {
"domain": [
"Actual",
"Forecast"
],
"range": [
[
0
],
[
4
]
]
}
}
}
},
{
"data": {
"values": [
{
"month": 24
}
]
},
"mark": "rule",
"encoding": {
"x": {
"field": "month",
"type": "quantitative"
},
"color": {
"value": "blue"
},
"size": {
"value": 2
}
}
}
]
},
{
"title": "Multivariate Forecast: Normalized Series",
"width": 300,
"height": 200,
"layer": [
{
"data": {
"sequence": {
"start": 0,
"stop": 30,
"step": 1,
"as": "month"
}
},
"transform": [
{
"calculate": "datum.month < 24 ? 'Actual' : 'Forecast'",
"as": "type"
},
{
"calculate": "datum.month <= 24 ? random() : datum.month == 24 ? datum.GDP : random() * 0.5 + 0.5",
"as": "GDP"
},
{
"calculate": "datum.month <= 24 ? random() : datum.month == 24 ? datum['S&P500'] : random() * 0.5 + 0.5",
"as": "S&P500"
},
{
"calculate": "datum.month <= 24 ? random() : datum.month == 24 ? datum.Unemployment : random() * 0.5 + 0.5",
"as": "Unemployment"
}
],
"layer": [
{
"mark": {
"type": "line",
"point": true
},
"encoding": {
"x": {
"field": "month",
"type": "quantitative",
"title": "Month"
},
"y": {
"field": "GDP",
"type": "quantitative"
},
"color": {
"value": "#00497677"
},
"strokeDash": {
"field": "type",
"type": "nominal",
"scale": {
"domain": [
"Actual",
"Forecast"
],
"range": [
[
0
],
[
4
]
]
}
}
}
},
{
"mark": {
"type": "line",
"point": true
},
"encoding": {
"x": {
"field": "month",
"type": "quantitative"
},
"y": {
"field": "S&P500",
"type": "quantitative"
},
"color": {
"value": "#7F3C8D77"
},
"strokeDash": {
"field": "type",
"type": "nominal",
"scale": {
"domain": [
"Actual",
"Forecast"
],
"range": [
[
0
],
[
4
]
]
}
}
}
},
{
"mark": {
"type": "line",
"point": true
},
"encoding": {
"x": {
"field": "month",
"type": "quantitative"
},
"y": {
"field": "Unemployment",
"type": "quantitative"
},
"color": {
"value": "#11A57977"
},
"strokeDash": {
"field": "type",
"type": "nominal",
"scale": {
"domain": [
"Actual",
"Forecast"
],
"range": [
[
0
],
[
4
]
]
}
}
}
}
]
},
{
"data": {
"values": [
{
"month": 24
}
]
},
"mark": "rule",
"encoding": {
"x": {
"field": "month",
"type": "quantitative"
},
"color": {
"value": "blue"
},
"size": {
"value": 2
}
}
}
]
},
{
"title": "Long-Term Forecast: GDP % Change",
"width": 300,
"height": 200,
"layer": [
{
"data": {
"sequence": {
"start": 0,
"stop": 84,
"step": 1,
"as": "month"
}
},
"transform": [
{
"calculate": "datum.month < 60 ? 'Actual' : 'Forecast'",
"as": "type"
},
{
"calculate": "datum.month <= 60 ? random() * 4 - 2 : datum.month == 60 ? datum.value : random() * 3 - 1.5",
"as": "value"
}
],
"mark": {
"type": "line",
"point": true
},
"encoding": {
"x": {
"field": "month",
"type": "quantitative",
"title": "Month"
},
"y": {
"field": "value",
"type": "quantitative",
"title": "% Change"
},
"color": {
"value": "#00497677"
},
"strokeDash": {
"field": "type",
"type": "nominal",
"scale": {
"domain": [
"Actual",
"Forecast"
],
"range": [
[
0
],
[
4
]
]
}
}
}
},
{
"data": {
"values": [
{
"month": 60
}
]
},
"mark": "rule",
"encoding": {
"x": {
"field": "month",
"type": "quantitative"
},
"color": {
"value": "blue"
},
"size": {
"value": 2
}
}
}
]
}
]
}