sampler_RW_NN_GP: NNGP-Specific Random Walk Metropolis-Hastings Sampler

sampler_RW_NN_GPR Documentation

NNGP-Specific Random Walk Metropolis-Hastings Sampler

Description

A custom NIMBLE sampler for updating individual spatial random effects under a Nearest-Neighbor Gaussian Process (NNGP) approximation. This sampler uses a factorized likelihood approach to perform highly efficient local Metropolis-Hastings sampling with a normal proposal distribution (Metropolis, 1953), implementing the adaptation routine given in Shaby and Wells (2011).

Usage

sampler_RW_NN_GP(model, mvSaved, target, control)

Arguments

model

(uncompiled) model on which the MCMC is to be run

mvSaved

modelValues object to be used to store MCMC samples

target

The node to be sampled (a single spatial random effect scalar).

control

A list of control parameters:

  • AD: Character (default "AD"). The name of the matrix containing the NNGP coefficients within the NIMBLE model object.

  • neighbors.id: Character (default "neighbors.id"). The name of the forward neighbor matrix within the NIMBLE model object.

  • adaptive: Logical (default TRUE). Whether to use an adaptive step-size procedure.

  • adaptInterval: Integer (default 200). Number of iterations between adaptive adjustments.

  • scale: Numeric (default 1). Initial scale/standard deviation for the random walk proposal.

Details

Instead of calculating the full NNGP log-likelihood, which is O(M) (where M is the total number of spatial locations), this sampler exploits the Directed Acyclic Graph (DAG) structure of the NNGP to reduce the complexity of a single-node update to O(k^2), where k is the number of neighbors.

During the MCMC configuration stage, the sampler automatically queries the local graph architecture using get_single_reverse_neighbors and RWNNGP_setup to resolve dependencies internally. When a single node w_i is updated, only its own conditional density and the conditional densities of its "children" (the reverse neighbors that depend on it) are affected.

The local log-Metropolis-Hastings ratio (\log MHR) is calculated as:

\log MHR = -\frac{(r_i^{*2} - r_i^2)}{2D_i} + \sum_{j \in \mathcal{R}(i)} -\frac{(r_j^{*2} - r_j^2)}{2D_j}

where:

  • r_i and r_i^* are the current and proposed conditional residuals for the target node.

  • \mathcal{R}(i) is the set of reverse neighbors (indices j such that i \in N(j)).

  • r_j and r_j^* are the current and proposed residuals for those reverse neighbors.

  • D represents the conditional variances.

The residuals are updated efficiently using the difference \delta = w_i^* - w_i, such that r_j^* = r_j - A_{ji}\delta, where A_{ji} is the NNGP regression coefficient.

Author(s)

Fabian Ketwaroo

References

Metropolis, N., Rosenbluth, A. W., Rosenbluth, M. N., Teller, A. H., and Teller, E. (1953). Equation of state calculations by fast computing machines. *The Journal of Chemical Physics*, 21(6), 1087-1092.

Shaby, B. A. and Wells, M. T. (2011). Exploring an adaptive Metropolis-Hastings algorithm. *Department of Statistical Science, Cornell University Tech Report*.


BayesNSGP documentation built on Sept. 10, 2026, 5:08 p.m.