Replicate an areal graph across the levels of a factor (replicated CAR)
Source:R/spatial_field.R
tulpa_bar_field_replicate.RdBuild the block-diagonal Kronecker graph I_L (x) Q and the level-offset
node index for a replicated areal field: one independent copy of the graph
per level of a by factor, all sharing one precision. This is the
graph-side counterpart to tulpa_bar_field_specs() – that helper expands
the coefficient columns and is graph-agnostic, while replication needs the
graph, so it is a sibling rather than a new argument. A downstream package
composes the two (column expansion x replication) from the one
implementation rather than re-deriving the Kronecker remap.
Arguments
- adjacency
Symmetric adjacency matrix of the base graph (
[n_node x n_node], dense or sparse).- node
Integer vector of 1-based graph-node indices, one per observation (the resolved bar right-hand side).
- by
A vector of the same length as
nodegiving each observation's replication level; coerced to a factor. WithLdistinct levels the field is replicatedLtimes.
Value
A list:
adjacencythe
[L*n_node x L*n_node]block-diagonal Kronecker adjacencyI_L (x) Q(the base graph forL == 1).indexinteger vector, one per observation: the node index offset into its level's copy (
node + (level - 1) * n_node).n_levelsthe number of replication levels
L.n_nodesthe base graph node count
n_node.levelsthe factor levels of
by, in replicate order.
See also
tulpa_bar_field_specs() for the coefficient-column expansion,
spatial() for the inline areal field constructor whose by = argument
this powers.