Learn R Programming

dcce (version 0.4.2)

.build_spatial_csa: Build spatial (local) cross-sectional averages

Description

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.

Usage

.build_spatial_csa(panel, vars, W, lags = 0L)

Value

The panel with new csa_* columns appended.

Arguments

panel

A panel data.frame from .make_panel().

vars

Character vector of variables to build spatial CSAs for.

W

A validated spatial weight matrix from .spatial_validate_W(), with rows/columns labelled by unit id.

lags

Integer scalar or named integer vector of lag orders. Default 0L (contemporaneous only).

Details

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.