Implements the Regional Graph Convolutional Network (RegConv) layer from Guo et al. (2025):
$$\mathbf{X}^{(l)} = \sigma\left(\left(\mathbf{D}^{-1}\mathbf{A}\mathbf{X}^{(l-1)}\boldsymbol{\Theta}^{(l)} + \mathbf{X}^{(l-1)}\boldsymbol{\Phi}^{(l)}\right)\boldsymbol{\Omega}_{reg}^{(l)} + \boldsymbol{\Psi}_{reg}^{(l)}\right)$$
This layer extends the standard GCN layer by introducing region-specific parameters to handle spatial heterogeneity (spatial regimes). The computation has two stages:
Base GCN transformation: \(\mathbf{D}^{-1}\mathbf{A}\mathbf{X}^{(l-1)}\boldsymbol{\Theta}^{(l)} + \mathbf{X}^{(l-1)}\boldsymbol{\Phi}^{(l)}\)
Region-specific modulation: Element-wise multiplication by \(\boldsymbol{\Omega}_{reg}\) and addition of \(\boldsymbol{\Psi}_{reg}\)
Parameters:
\(\Theta\) (theta):
in_features x out_featurestransforms aggregated neighbor features (global)\(\Phi\) (phi):
in_features x out_featurestransforms node's own features (global)\(\Omega_{reg}\) (omega_reg):
n_regions x out_featuresregion-specific weight modulation\(\Psi_{reg}\) (psi_reg):
n_regions x out_featuresregion-specific bias terms
Details
The RegConv layer is designed for two-stage training:
Stage 1: Train a global GCN to learn \(\Theta\) and \(\Phi\), then freeze these parameters.
Stage 2: Initialize \(\Omega_{reg}\) to all 1s and train region-specific parameters (\(\Omega_{reg}\), \(\Psi_{reg}\)) while keeping \(\Theta\) and \(\Phi\) fixed.
The region-specific parameters allow the model to adjust predictions differently across spatial regimes, enabling the model to capture spatial heterogeneity.
Forward pass
layer(x, adj, region_assignments, edge_weight = NULL)
x: Tensorn_nodes x in_features. Node feature matrix.adj: Sparse COO tensorn_nodes x n_nodes. Adjacency matrix, expected to be row-normalized \(D^{-1}A\) where \(D\) is the degree matrix. Can be binary or weighted.region_assignments: Tensorn_nodes. Integer vector with values in1:n_regionsgiving the region each node belongs to. Multiple nodes can belong to the same region.edge_weight: Tensorn_nodes x n_nodesorNULL. Optional edge weights applied to the adjacency matrix. IfNULL, the values ofadjare used.
References
Guo, H., Wang, H., Zhu, D., Wu, L., Fotheringham, A. S., & Liu, Y. (2025). RegionGCN: Spatial-Heterogeneity-Aware Graph Convolutional Networks. Annals of the American Association of Geographers, 1–17. doi:10.1080/24694452.2025.2558661
Examples
if (FALSE) { # torch::torch_is_installed()
adj <- adj_from_edgelist(from = c(1, 2, 3, 4), to = c(2, 3, 4, 1))
x <- torch::torch_randn(4, 8)
# This layer expects a row-normalized adjacency matrix
adj_norm <- adj_row_normalize(add_graph_self_loops(adj))
# Four nodes split across two spatial regimes
regions <- torch::torch_tensor(c(1, 1, 2, 2), dtype = torch::torch_long())
layer <- layer_regconv(8, 4, n_regions = 2)
layer(x, adj_norm, regions)
}