Follow ______ on twitter.

7.2.1 Differentiating among time series techniques

Code

Vega-Lite Chart

{
  "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
  "description": "Comparison of Time Series Models with Forecasts",
  "data": {
    "values": [
      {
        "time": "2022-01",
        "actual": 100,
        "SMA": null,
        "ES": null,
        "ARIMA": null
      },
      {
        "time": "2022-02",
        "actual": 120,
        "SMA": null,
        "ES": 110,
        "ARIMA": 110
      },
      {
        "time": "2022-03",
        "actual": 90,
        "SMA": 103.33,
        "ES": 100,
        "ARIMA": 105
      },
      {
        "time": "2022-04",
        "actual": 110,
        "SMA": 106.67,
        "ES": 105,
        "ARIMA": 100
      },
      {
        "time": "2022-05",
        "actual": 130,
        "SMA": 110,
        "ES": 117.5,
        "ARIMA": 115
      },
      {
        "time": "2022-06",
        "actual": 140,
        "SMA": 126.67,
        "ES": 128.75,
        "ARIMA": 135
      },
      {
        "time": "2022-07",
        "actual": 135,
        "SMA": 135,
        "ES": 131.88,
        "ARIMA": 138
      },
      {
        "time": "2022-08",
        "actual": 145,
        "SMA": 140,
        "ES": 138.44,
        "ARIMA": 140
      },
      {
        "time": "2022-09",
        "actual": 150,
        "SMA": 143.33,
        "ES": 144.22,
        "ARIMA": 147
      },
      {
        "time": "2022-10",
        "actual": 160,
        "SMA": 151.67,
        "ES": 152.11,
        "ARIMA": 155
      },
      {
        "time": "2022-11",
        "actual": null,
        "SMA": 151.67,
        "ES": 156.06,
        "ARIMA": 163
      },
      {
        "time": "2022-12",
        "actual": null,
        "SMA": 151.67,
        "ES": 158.03,
        "ARIMA": 165
      },
      {
        "time": "2023-01",
        "actual": null,
        "SMA": 151.67,
        "ES": 159.01,
        "ARIMA": 167
      }
    ]
  },
  "width": 400,
  "height": 300,
  "transform": [
    {
      "fold": [
        "actual",
        "SMA",
        "ES",
        "ARIMA"
      ],
      "as": [
        "model",
        "value"
      ]
    }
  ],
  "mark": {
    "type": "line",
    "point": true
  },
  "encoding": {
    "x": {
      "field": "time",
      "type": "temporal",
      "title": "Time"
    },
    "y": {
      "field": "value",
      "type": "quantitative",
      "title": "Value",
      "scale": {
        "domain": [
          80,
          170
        ]
      }
    },
    "color": {
      "field": "model",
      "type": "nominal",
      "title": "Model",
      "scale": {
        "domain": [
          "actual",
          "SMA",
          "ES",
          "ARIMA"
        ],
        "range": [
          "#1f77b4",
          "#ff7f0e",
          "#2ca02c",
          "#d62728"
        ]
      }
    },
    "tooltip": [
      {
        "field": "time",
        "type": "temporal",
        "title": "Time"
      },
      {
        "field": "value",
        "type": "quantitative",
        "title": "Value"
      },
      {
        "field": "model",
        "type": "nominal",
        "title": "Model"
      }
    ]
  },
  "config": {
    "legend": {
      "title": null,
      "orient": "top",
      "direction": "horizontal"
    }
  }
}