View source: R/v03_RWNNGP_sampler.R
| get_single_reverse_neighbors | R Documentation |
Identifies all "children" (reverse neighbors) for a specific target location
j in a Nearest-Neighbor Gaussian Process (NNGP). It searches the neighbor matrix
to find all locations k that condition upon location j.
get_single_reverse_neighbors(target_node, neighbor_idx)
target_node |
Integer. The index of the location |
neighbor_idx |
Integer matrix ( |
This function optimizes the reverse lookup for a single node by avoiding the
full O(M) list construction loop. It uses vectorization to scan rows of
the neighbor matrix where the row index k is greater than the target index
j, enforcing the Directed Acyclic Graph (DAG) structure of the NNGP.
An integer vector containing the indices of all locations k
that have target_node as a neighbor, maintaining the NNGP
ordering constraint (j < k).
Fabian Ketwaroo
nn_matrix <- matrix(c(0, 0,
1, 0,
1, 2,
1, 3), nrow = 4, byrow = TRUE)
# Find which nodes have node 1 as a neighbor
get_single_reverse_neighbors(target_node = 1, neighbor_idx = nn_matrix)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.