Follow ______ on twitter.

7.2.4 Decompositon with Exponential Smoothing Techniques

Code

Vega-Lite Chart

{
  "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
  "data": {
    "values": [
      {
        "date": "2022-01-01",
        "value": 100,
        "SES": 100,
        "Holt": 100,
        "HoltWinters": 100
      },
      {
        "date": "2022-02-01",
        "value": 110,
        "SES": 105,
        "Holt": 107,
        "HoltWinters": 108
      },
      {
        "date": "2022-03-01",
        "value": 130,
        "SES": 117.5,
        "Holt": 122,
        "HoltWinters": 125
      },
      {
        "date": "2022-04-01",
        "value": 120,
        "SES": 118.75,
        "Holt": 123,
        "HoltWinters": 122
      },
      {
        "date": "2022-05-01",
        "value": 140,
        "SES": 129.375,
        "Holt": 135,
        "HoltWinters": 138
      },
      {
        "date": "2022-06-01",
        "value": 150,
        "SES": 139.6875,
        "Holt": 147,
        "HoltWinters": 149
      },
      {
        "date": "2022-07-01",
        "value": 160,
        "SES": 149.84375,
        "Holt": 159,
        "HoltWinters": 161
      },
      {
        "date": "2022-08-01",
        "value": 170,
        "SES": 159.921875,
        "Holt": 171,
        "HoltWinters": 172
      },
      {
        "date": "2022-09-01",
        "value": 180,
        "SES": 169.9609375,
        "Holt": 183,
        "HoltWinters": 184
      },
      {
        "date": "2022-10-01",
        "value": 190,
        "SES": 179.98046875,
        "Holt": 195,
        "HoltWinters": 196
      }
    ]
  },
  "hconcat": [
    {
      "width": 300,
      "height": 200,
      "title": "Original Data vs. Exponential Smoothing Techniques",
      "layer": [
        {
          "mark": "line",
          "encoding": {
            "x": {
              "field": "date",
              "type": "temporal"
            },
            "y": {
              "field": "value",
              "type": "quantitative",
              "scale": {
                "domain": [
                  90,
                  200
                ]
              }
            },
            "color": {
              "value": "black"
            },
            "strokeDash": {
              "value": [
                1,
                0
              ]
            },
            "tooltip": [
              {
                "field": "date",
                "type": "temporal",
                "title": "Date"
              },
              {
                "field": "value",
                "type": "quantitative",
                "title": "Original Value"
              }
            ]
          }
        },
        {
          "mark": "line",
          "encoding": {
            "x": {
              "field": "date",
              "type": "temporal"
            },
            "y": {
              "field": "SES",
              "type": "quantitative"
            },
            "color": {
              "value": "blue"
            },
            "strokeDash": {
              "value": [
                5,
                5
              ]
            },
            "tooltip": [
              {
                "field": "date",
                "type": "temporal",
                "title": "Date"
              },
              {
                "field": "SES",
                "type": "quantitative",
                "title": "SES Value"
              }
            ]
          }
        },
        {
          "mark": "line",
          "encoding": {
            "x": {
              "field": "date",
              "type": "temporal"
            },
            "y": {
              "field": "Holt",
              "type": "quantitative"
            },
            "color": {
              "value": "green"
            },
            "strokeDash": {
              "value": [
                2,
                2
              ]
            },
            "tooltip": [
              {
                "field": "date",
                "type": "temporal",
                "title": "Date"
              },
              {
                "field": "Holt",
                "type": "quantitative",
                "title": "Holt Value"
              }
            ]
          }
        },
        {
          "mark": "line",
          "encoding": {
            "x": {
              "field": "date",
              "type": "temporal"
            },
            "y": {
              "field": "HoltWinters",
              "type": "quantitative"
            },
            "color": {
              "value": "red"
            },
            "strokeDash": {
              "value": [
                1,
                1
              ]
            },
            "tooltip": [
              {
                "field": "date",
                "type": "temporal",
                "title": "Date"
              },
              {
                "field": "HoltWinters",
                "type": "quantitative",
                "title": "Holt-Winters Value"
              }
            ]
          }
        },
        {
          "mark": {
            "type": "rule"
          },
          "data": {
            "values": [
              {
                "method": "Original"
              },
              {
                "method": "SES"
              },
              {
                "method": "Holt"
              },
              {
                "method": "Holt-Winters"
              }
            ]
          },
          "encoding": {
            "strokeDash": {
              "field": "Method",
              "type": "nominal",
              "scale": {
                "domain": [
                  "Original",
                  "SES",
                  "Holt",
                  "Holt-Winters"
                ],
                "range": [
                  [
                    1,
                    0
                  ],
                  [
                    5,
                    5
                  ],
                  [
                    2,
                    2
                  ],
                  [
                    1,
                    1
                  ]
                ]
              }
            }
          }
        }
      ],
      "resolve": {
        "scale": {
          "color": "independent"
        }
      },
      "encoding": {
        "x": {
          "field": "date",
          "type": "temporal",
          "axis": {
            "title": "Date"
          }
        },
        "y": {
          "type": "quantitative",
          "axis": {
            "title": "Value"
          }
        }
      }
    },
    {
      "width": 300,
      "height": 200,
      "title": "Trend Component (Holt and Holt-Winters)",
      "mark": "line",
      "encoding": {
        "x": {
          "field": "date",
          "type": "temporal"
        },
        "y": {
          "field": "Holt",
          "type": "quantitative"
        },
        "color": {
          "value": "green"
        }
      }
    },
    {
      "width": 300,
      "height": 200,
      "title": "Seasonal Component (Holt-Winters)",
      "mark": "line",
      "transform": [
        {
          "calculate": "datum.HoltWinters - datum.Holt",
          "as": "seasonal"
        }
      ],
      "encoding": {
        "x": {
          "field": "date",
          "type": "temporal"
        },
        "y": {
          "field": "seasonal",
          "type": "quantitative"
        },
        "color": {
          "value": "red"
        }
      }
    }
  ]
}