{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"description": "ARIMA and ARIMAX Model Application with Flat Delinquency Rate and Unemployment Rate",
"data": {
"sequence": {
"start": 1,
"stop": 1091,
"step": 1,
"as": "day"
}
},
"transform": [
{
"calculate": "if(datum.day <= 730, 1.5 + 0.005 * sin(2 * PI * datum.day / 365) + sampleNormal(0, 0.1), null)",
"as": "delinquency_rate"
},
{
"calculate": "if(datum.day <= 730, 5 + sampleNormal(0, 0.5), 5 + (datum.day - 730) / 360 * 10)",
"as": "unemployment_rate"
},
{
"calculate": "datum.day > 730 ? datum.day : null",
"as": "future_day"
}
],
"hconcat": [
{
"title": "Delinquency Rate and ARIMA Forecast",
"layer": [
{
"mark": "line",
"encoding": {
"x": {
"field": "day",
"type": "quantitative",
"title": "Day"
},
"y": {
"field": "delinquency_rate",
"type": "quantitative",
"title": "Delinquency Rate (%)",
"scale": {
"domain": [
0.5,
3
]
}
},
"color": {
"value": "lightgray"
}
}
},
{
"transform": [
{
"filter": "datum.future_day"
},
{
"calculate": "1.5 + sampleNormal(0, 0.1)",
"as": "forecast_delinquency_rate"
}
],
"mark": "line",
"encoding": {
"x": {
"field": "future_day",
"type": "quantitative"
},
"y": {
"field": "forecast_delinquency_rate",
"type": "quantitative",
"scale": {
"domain": [
0.5,
3
]
}
},
"color": {
"value": "blue"
}
}
},
{
"mark": {
"type": "rule",
"color": "red"
},
"encoding": {
"x": {
"datum": 730,
"type": "quantitative"
}
}
}
]
},
{
"title": "Unemployment Rate and Forecast",
"layer": [
{
"mark": "line",
"encoding": {
"x": {
"field": "day",
"type": "quantitative",
"title": "Day"
},
"y": {
"field": "unemployment_rate",
"type": "quantitative",
"title": "Unemployment Rate (%)",
"scale": {
"domain": [
0,
20
]
}
},
"color": {
"value": "green"
}
}
}
]
},
{
"title": "Delinquency Rate and ARIMAX Forecast",
"layer": [
{
"mark": "line",
"encoding": {
"x": {
"field": "day",
"type": "quantitative",
"title": "Day"
},
"y": {
"field": "delinquency_rate",
"type": "quantitative",
"title": "Delinquency Rate (%)",
"scale": {
"domain": [
0.5,
3
]
}
},
"color": {
"value": "lightgray"
}
}
},
{
"transform": [
{
"filter": "datum.future_day"
},
{
"calculate": "1.5 + 0.1 * (datum.unemployment_rate - 5) + sampleNormal(0, 0.1)",
"as": "conditional_forecast"
}
],
"mark": "line",
"encoding": {
"x": {
"field": "future_day",
"type": "quantitative"
},
"y": {
"field": "conditional_forecast",
"type": "quantitative",
"title": "ARIMAX Forecast",
"scale": {
"domain": [
0.5,
3
]
}
},
"color": {
"value": "red"
}
}
},
{
"mark": {
"type": "rule",
"color": "red"
},
"encoding": {
"x": {
"datum": 730,
"type": "quantitative"
}
}
}
]
}
]
}