Skip to content

Home / Statistical Tools / Analysis Tools / Time Series / Math Details

Math Details

This page gives the exact formulas Quantum XL uses across the Time Series tools (smoothing, trend, and correlation). Each equation lists what it computes and where it appears in the output.

Notation

Term Description
\(y_1, \dots, y_N\) the time-ordered series values (\(N\) periods; some may be missing)
\(N\) number of periods in the series
\(\bar{y}\) mean of the series (over non-missing points)
\(\hat{y}_t\) fitted (one-step-ahead) value at period \(t\)
\(e_t\) forecast error, \(e_t = y_t - \hat{y}_t\)
\(r_k\) autocorrelation at lag \(k\)

Moving average

A trailing average over a window of \(L\) periods:

\[ \hat{y}_t = \frac{1}{L}\sum_{j = t - L + 1}^{t} y_j \qquad (t \ge L) \]

The first \(L - 1\) periods have no fitted value. If any value in the window is missing, that fitted value is undefined.

Double exponential smoothing (Holt's method)

Two coupled recursions track a level \(L_t\) and a trend \(T_t\). They are initialized from a linear regression of \(y\) on time (\(L_0 =\) intercept at \(t = 0\), \(T_0 =\) slope):

\[ \hat{y}_t = L_{t-1} + T_{t-1} \]
\[ L_t = \alpha\,y_t + (1 - \alpha)\left(L_{t-1} + T_{t-1}\right) \]
\[ T_t = \gamma\left(L_t - L_{t-1}\right) + (1 - \gamma)\,T_{t-1} \]
Term Description
\(\alpha\) level smoothing constant, \(0 \le \alpha \le 1\)
\(\gamma\) trend smoothing constant, \(0 \le \gamma \le 1\)

Forecasts \(m\) periods beyond the series extend the final level along the final trend:

\[ \hat{y}_{N+m} = L_N + m\,T_N \]

Trend analysis

A least-squares fit of the series against the period index \(t\) (solved by weighted QR decomposition):

\[ \text{Linear:}\quad \hat{y}_t = a + b\,t \qquad\qquad \text{Quadratic:}\quad \hat{y}_t = a + b\,t + c\,t^2 \]

Forecast accuracy measures

With \(e_t = y_t - \hat{y}_t\) over the \(n\) periods that have both an actual and a fitted value:

\[ \text{MAPE} = \frac{100}{n}\sum_{t}\left|\frac{e_t}{y_t}\right|\ \ (y_t \ne 0), \qquad \text{MAD} = \frac{1}{n}\sum_{t}\lvert e_t \rvert, \qquad \text{MSD} = \frac{1}{n}\sum_{t} e_t^{2} \]

Autocorrelation function (ACF)

\[ r_k = \frac{\displaystyle\sum_{t=1}^{N-k}(y_t - \bar{y})(y_{t+k} - \bar{y})}{\displaystyle\sum_{t=1}^{N}(y_t - \bar{y})^2} \]

with \(r_0 = 1\). The standard error uses Bartlett's formula, and the significance is summarized by a \(t\) statistic and the Ljung–Box \(Q\):

\[ SE_k = \sqrt{\frac{1}{N}\left(1 + 2\sum_{j=1}^{k-1} r_j^{2}\right)}, \qquad t_k = \frac{r_k}{SE_k}, \qquad Q_k = N(N + 2)\sum_{j=1}^{k}\frac{r_j^{2}}{N - j} \]

The confidence limits drawn on the plot are \(\pm\, t_{\,N-1,\ 0.975}\, SE_k\).

Partial autocorrelation function (PACF)

Computed from the ACF by the Durbin–Levinson recursion. With \(\phi_{1,1} = r_1\) and \(v_0 = 1 - r_1^{2}\), for \(k \ge 2\):

\[ \phi_{k,k} = \frac{r_k - \sum_{j=1}^{k-1}\phi_{k-1,j}\,r_{k-j}}{v_{k-1}}, \qquad \phi_{k,j} = \phi_{k-1,j} - \phi_{k,k}\,\phi_{k-1,k-j}, \qquad v_{k-1} = v_{k-2}\left(1 - \phi_{k-1,k-1}^{2}\right) \]

The PACF at lag \(k\) is \(\phi_{k,k}\), with \(t_k = \phi_{k,k}\sqrt{N}\). Its confidence limits are flat at \(\pm\, t_{\,N-1,\ 0.975}/\sqrt{N}\).

Cross-correlation function (CCF)

For two series \(x\) and \(y\), at lag \(k \in [-K, +K]\):

\[ r_k(x, y) = \frac{\displaystyle\sum_{t}(x_t - \bar{x})(y_{t+k} - \bar{y})}{n\,s_x\,s_y} \]
Term Description
\(s_x, s_y\) standard deviations of each series computed separately with an \(n\) (population) divisor
\(n\) number of valid paired observations at that lag

Lag selection

When lags are chosen automatically, the autocorrelation and partial autocorrelation use \(\lfloor N/4 \rfloor\) lags for \(N \le 240\), and \(\lfloor \sqrt{N} + 45 \rfloor\) otherwise. Cross-correlation uses a separate rule, \(\lfloor \sqrt{N} + 10 \rfloor\) lags. Both are capped at \(N - 1\).

References

  • Box, G. E. P., Jenkins, G. M., & Reinsel, G. C. (2008). Time Series Analysis: Forecasting and Control (4th ed.). Hoboken, NJ: John Wiley & Sons.
  • Ljung, G. M., & Box, G. E. P. (1978). On a measure of lack of fit in time series models. Biometrika, 65(2), 297–303.
  • Holt, C. C. (2004). Forecasting seasonals and trends by exponentially weighted moving averages. International Journal of Forecasting, 20(1), 5–10.
  • Brockwell, P. J., & Davis, R. A. (1991). Time Series: Theory and Methods (2nd ed.). New York: Springer-Verlag.
  • Chatfield, C. (2003). The Analysis of Time Series: An Introduction (6th ed.). Boca Raton, FL: Chapman & Hall/CRC.
  • Hyndman, R. J., & Athanasopoulos, G. (2021). Forecasting: Principles and Practice (3rd ed.). Melbourne: OTexts.