Constructs the \(n \times n_b\) structural matrix \(\mathbf{S}\) for a set of linearly related time series, where \(n\) is the total number of series and \(n_b\) is the number of bottom-level series.
coherent_smat(data, sparse = FALSE)An \(n \times n_b\) matrix (dense or sparse) encoding the structural relationships among all series.
Let \(\boldsymbol{b}_t\) be the \(n_b\)-vector of bottom-level series at time \(t\), and \(\boldsymbol{a}_t = \mathbf{A}\boldsymbol{b}_t\) be the \(n_a = n - n_b\) aggregated series, where \(\mathbf{A}\) is the \(n_a \times n_b\) aggregation matrix. The full \(n\)-vector of series is \(\boldsymbol{y}_t = [\boldsymbol{a}_t', \boldsymbol{b}_t']'\), and the structural matrix satisfies
$$\boldsymbol{y}_t = \mathbf{S}\boldsymbol{b}_t, \quad \mathbf{S} = \begin{bmatrix} \mathbf{A} \\ \mathbf{I}_{n_b} \end{bmatrix}.$$
Any linear reconciliation method can be written as
\(\tilde{\boldsymbol{y}}_h = \mathbf{S}\mathbf{G}\hat{\boldsymbol{y}}_h\),
where \(\hat{\boldsymbol{y}}_h\) are the \(h\)-step base forecasts.
Optimal reconciled forecasts use
\(\mathbf{G} = (\mathbf{S}'\mathbf{W}^{-1}\mathbf{S})^{-1}\mathbf{S}'\mathbf{W}^{-1}\),
with \(\mathbf{W}\) a positive definite weight matrix (see
min_trace()).
Hyndman, R. J., & Athanasopoulos, G. (2022). Notation for forecast reconciliation. https://robjhyndman.com/hyndsight/reconciliation-notation.html
coherent_cmat() for the corresponding zero-constraint matrix
\(\mathbf{C}\) and aggregate_key() for computing cross-sectional
aggregations with tsibble data sets.
tsibble::tourism %>%
aggregate_key(Purpose, Trips = sum(Trips)) %>%
coherent_smat()
#> [,1] [,2] [,3] [,4]
#> [1,] 1 1 1 1
#> [2,] 1 0 0 0
#> [3,] 0 1 0 0
#> [4,] 0 0 1 0
#> [5,] 0 0 0 1