Follow ______ on twitter.

7.5.3 Data quality considerations for time-series forecasting

Code

Vega-Lite Chart

{
  "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
  "description": "Time Series Data Transformations",
  "hconcat": [
    {
      "title": "Original vs Differenced",
      "width": 300,
      "height": 200,
      "data": {
        "values": [
          {
            "time": 0,
            "original": 10,
            "differenced": 0
          },
          {
            "time": 1,
            "original": 12,
            "differenced": 2
          },
          {
            "time": 2,
            "original": 15,
            "differenced": 3
          },
          {
            "time": 3,
            "original": 14,
            "differenced": -1
          },
          {
            "time": 4,
            "original": 18,
            "differenced": 4
          },
          {
            "time": 5,
            "original": 20,
            "differenced": 2
          }
        ]
      },
      "transform": [
        {
          "fold": [
            "original",
            "differenced"
          ],
          "as": [
            "series",
            "value"
          ]
        }
      ],
      "mark": "line",
      "encoding": {
        "x": {
          "field": "time",
          "type": "quantitative",
          "title": "Time"
        },
        "y": {
          "field": "value",
          "type": "quantitative",
          "title": "Value"
        },
        "color": {
          "field": "series",
          "type": "nominal",
          "scale": {
            "domain": [
              "original",
              "differenced"
            ],
            "range": [
              "#00497677",
              "#ff7f0e"
            ]
          },
          "title": "Series"
        }
      }
    },
    {
      "title": "Original vs Normalized vs Standardized",
      "width": 300,
      "height": 200,
      "data": {
        "values": [
          {
            "time": 0,
            "original": 10,
            "normalized": 0,
            "standardized": -1.46
          },
          {
            "time": 1,
            "original": 12,
            "normalized": 0.2,
            "standardized": -0.73
          },
          {
            "time": 2,
            "original": 15,
            "normalized": 0.5,
            "standardized": 0.36
          },
          {
            "time": 3,
            "original": 14,
            "normalized": 0.4,
            "standardized": 0
          },
          {
            "time": 4,
            "original": 18,
            "normalized": 0.8,
            "standardized": 1.09
          },
          {
            "time": 5,
            "original": 20,
            "normalized": 1,
            "standardized": 1.82
          }
        ]
      },
      "transform": [
        {
          "fold": [
            "original",
            "normalized",
            "standardized"
          ],
          "as": [
            "series",
            "value"
          ]
        }
      ],
      "mark": "line",
      "encoding": {
        "x": {
          "field": "time",
          "type": "quantitative",
          "title": "Time"
        },
        "y": {
          "field": "value",
          "type": "quantitative",
          "title": "Value"
        },
        "color": {
          "field": "series",
          "type": "nominal",
          "scale": {
            "domain": [
              "original",
              "normalized",
              "standardized"
            ],
            "range": [
              "#00497677",
              "#ff7f0e",
              "#2ca02c"
            ]
          },
          "title": "Series"
        }
      }
    },
    {
      "title": "Original vs Log-transformed",
      "width": 300,
      "height": 200,
      "data": {
        "values": [
          {
            "time": 0,
            "original": 100,
            "log": 4.61
          },
          {
            "time": 1,
            "original": 150,
            "log": 5.01
          },
          {
            "time": 2,
            "original": 200,
            "log": 5.3
          },
          {
            "time": 3,
            "original": 180,
            "log": 5.19
          },
          {
            "time": 4,
            "original": 250,
            "log": 5.52
          },
          {
            "time": 5,
            "original": 300,
            "log": 5.7
          },
          {
            "time": 6,
            "original": 280,
            "log": 5.63
          },
          {
            "time": 7,
            "original": 350,
            "log": 5.86
          },
          {
            "time": 8,
            "original": 400,
            "log": 5.99
          },
          {
            "time": 9,
            "original": 380,
            "log": 5.94
          }
        ]
      },
      "transform": [
        {
          "fold": [
            "original",
            "log"
          ],
          "as": [
            "series",
            "value"
          ]
        }
      ],
      "layer": [
        {
          "mark": "line",
          "encoding": {
            "x": {
              "field": "time",
              "type": "quantitative",
              "title": "Time"
            },
            "y": {
              "field": "value",
              "type": "quantitative",
              "title": "Value",
              "scale": {
                "type": "log"
              }
            },
            "color": {
              "field": "series",
              "type": "nominal",
              "scale": {
                "domain": [
                  "original",
                  "log"
                ],
                "range": [
                  "#00497677",
                  "#ff7f0e"
                ]
              },
              "title": "Series"
            }
          }
        }
      ]
    }
  ]
}