For each variable in vars and each unit \(i\) at time \(t\),
computes \(\bar y^W_{i,t} = \sum_j w_{ij} y_{j,t}\) where \(W\) is
the row-normalised spatial weight matrix. Appends these as new
columns on the panel, alongside lagged versions when requested.
.build_spatial_csa(panel, vars, W, lags = 0L)The panel with new csa_* columns appended.
A panel data.frame from .make_panel().
Character vector of variables to build spatial CSAs for.
A validated spatial weight matrix from
.spatial_validate_W(), with rows/columns labelled by unit id.
Integer scalar or named integer vector of lag orders.
Default 0L (contemporaneous only).
Compared to .build_csa() (which appends a single global series
per variable, broadcast to all units), the spatial variant produces
unit-specific values — each unit sees its own neighbourhood average.