Helpers to replace the global cross-sectional averages of classical CCE with spatially-weighted local averages. Given a row-normalised spatial weight matrix \(W\) (\(N \times N\), zero diagonal, rows summing to one), the cross-sectional average for unit \(i\) at time \(t\) becomes $$\bar{y}_{it} = \sum_{j=1}^N w_{ij} y_{jt},$$ i.e. a weighted average over unit \(i\)'s spatial neighbours rather than a global mean across the whole panel. This allows the common factor proxy to vary across units in a way that respects the spatial topology of the data (geographical contiguity, trade links, input- output connections, etc.).
The weight matrix is supplied directly by the user; dcce makes no
assumptions about how it was constructed. It must be square with
dimensions equal to the number of units, and rows should ideally sum
to one (the helper will row-normalise silently if they do not).