-1
$\begingroup$

Does anyone know how to manually perform calculations using STL Decomposition? I have this data:

Date Count
2017-01-31 68
2017-02-28 59
2017-03-31 75
2017-04-30 71
2017-05-31 70
2017-06-30 68
2017-07-31 73
2017-08-31 87
2017-09-30 69
2017-10-31 74
2017-11-30 83
2017-12-31 91
2018-01-31 53
2018-02-28 61
2018-03-31 73
2018-04-30 63
2018-05-31 52
2018-06-30 52
2018-07-31 71
2018-08-31 76
2018-09-30 66
2018-10-31 62
2018-11-30 48
2018-12-31 99
2019-01-31 60
2019-02-28 76
2019-03-31 71
2019-04-30 73
2019-05-31 56
2019-06-30 70
2019-07-31 73
2019-08-31 85
2019-09-30 65
2019-10-31 74
2019-11-30 73
2019-12-31 78
2020-01-31 69
2020-02-29 54
2020-03-31 32
2020-04-30 10
2020-05-31 10
2020-06-30 10
2020-07-31 10
2020-08-31 10
2020-09-30 10
2020-10-31 10
2020-11-30 10
2020-12-31 10
2021-01-31 10
2021-02-28 10
2021-03-31 10
2021-04-30 10
2021-05-31 10
2021-06-30 10
2021-07-31 10
2021-08-31 10
2021-09-30 10
2021-10-31 10
2021-11-30 10
2021-12-31 10
2022-01-31 10
2022-02-28 10
2022-03-31 10
2022-04-30 11
2022-05-31 21
2022-06-30 25
2022-07-31 31
2022-08-31 39
2022-09-30 27
2022-10-31 42
2022-11-30 40
2022-12-31 64
2023-01-31 50
2023-02-28 53
2023-03-31 56
2023-04-30 56
2023-05-31 57
2023-06-30 57
2023-07-31 60
2023-08-31 69
2023-09-30 55
2023-10-31 50

Please help me get the results from manual STL Decomposition calculations along with the formulas used. It doesn't have to be all of it, because what I need is the usage of formulas and the workflow until obtaining the Seasonal, Trend, Residual, and Deseasonalized components. The period used for this manual calculation is every 12 months. Oh yes, I have steps for performing STL Decomposition, which are roughly like this:

  1. The original time series is subtracted by the initial trend estimate (a constant value) to produce the de-trended time series.

    $$ x_t - \hat{T}_0 = x_t - \mu $$

  2. The de-trended time series is divided into ( k ) subseries and smoothed using LOESS with ( q ) neighboring observations, resulting in the smoothed subseries values (( \hat{s}_{it} )).

    $$ \hat{s}_{it} = \text{LOESS}(x_{it}, t_i, q) $$

    where,

    • ( \hat{s}_{it} ): Estimate of subseries value ( i ) at period ( t_i )
    • ( x_{it} ): Subseries observation value ( i ) at period ( t_i )
    • LOESS: LOESS regression function (Local Regression)
    • ( t_i ): Time (period) of subseries ( i )
    • ( q ): Number of neighboring observations used in LOESS regression
  3. The smoothed subseries are extrapolated for ( 2k ) out-of-sample observations.

  4. The smoothed subseries are filtered using several self-determined moving averages (MA) and LOESS with one neighboring observation, resulting in the initial seasonal component (( \hat{m}_t )).

    $$ \hat{m}_t = \text{MA}(t) \circ \text{LOESS}(\hat{s}_t, t, l) $$

    where,

    • ( \hat{m}_t ): Estimate of initial seasonal component at period ( t )
    • MA(( t )): Moving average at period ( t )
    • ( \circ ): Composition operator
    • LOESS(( \hat{s}_t, t, l )): LOESS regression function (Local Regression)
    • ( \hat{s}_t ): Smoothed subseries value at period ( t )
    • ( t ): Time (period) of the subseries
    • ( l ): Number of neighboring observations used in LOESS regression
  5. The initial seasonal component is subtracted from the filtered seasonal component to produce the final seasonal component (( \hat{c}_t )).

  6. The de-trended time series is subtracted by the final seasonal component to produce the seasonally adjusted time series.

    $$ x_t - \hat{T}_0 - \hat{c}_t = x_t - \mu - \hat{c}_t $$

  7. The seasonally adjusted time series is smoothed using LOESS with ( t ) neighboring observations, resulting in the trend component (( \hat{T}_t )).

    $$ \hat{T}_t = \text{LOESS}(x_t - \hat{\mu} - \hat{c}_t, t, t) $$

    where,

    • ( \hat{T}_t ): Estimate of the trend component at period ( t )
    • LOESS(( x_t - \hat{\mu} - \hat{c}_t, t, t )): LOESS regression function (Local Regression)
    • ( x_t ): Original time series observation value at period ( t )
    • ( \hat{\mu} ): Estimate of the time series mean value
    • ( \hat{c}_t ): Estimate of the seasonal component at period ( t )
    • ( t ): Time (period) of the time series
  8. The original time series is subtracted by the final seasonal component and the trend component to produce the irregular component (( \hat{R}_t )).

    $$ \hat{R}_t = x_t - \hat{\mu} - \hat{c}_t - \hat{T}_t $$

    where,

    • ( \hat{R}_t ): Estimate of the irregular component at period ( t )
    • ( x_t ): Original time series observation value at period ( t )
    • ( \hat{\mu} ): Estimate of the time series mean value
    • ( \hat{c}_t ): Estimate of the seasonal component at period ( t )
    • ( \hat{T}_t ): Estimate of the trend component at period ( t )
    • ( t ): Time (period) of the time series
  9. Outlier-based weights are assigned from the irregular component.

  10. Outlier-based weights are reused in the subsequent steps, repeating again from step 1.

Please also check if the steps are correct or incorrect like this.

New contributor
Devri Zefanya is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
$\endgroup$

0

Browse other questions tagged .