computeAD: Compute NNGP regression coefficients and conditional...

computeADR Documentation

Compute NNGP regression coefficients and conditional variances

Description

Computes the Nearest-Neighbor Gaussian Process (NNGP) factorization components for each location: the regression coefficients (A) and conditional variances (D) following the algorithms described by Finley et al. (2019)

Usage

computeAD(edist, nid.dist, neighbors.id, rho, sigma2, k)

Arguments

edist

Numeric matrix (M \times M). Pairwise Euclidean distances between spatial locations.

nid.dist

Numeric matrix (M \times (k+1)). Distances from each location to its ordered neighbor set, including self-distance in the last column.

neighbors.id

Integer matrix (M \times k). Indices of neighbor locations for each spatial location, based on the chosen ordering.

rho

Positive numeric scalar. Length-scale parameter \rho.

sigma2

Positive numeric scalar. Marginal variance \sigma^2.

k

Positive integer. Maximum number of neighbors.

Details

This function computes the parameters of the NNGP factorization by expressing the joint distribution as a product of conditional Gaussian densities:

p(\mathbf{x}) = \prod_{i=1}^M p(x_i \mid x_{N(i)})

where N(i) denotes the set of neighbors of location i.

For each location i, the conditional distribution is:

x_i \mid x_{N(i)} \sim \mathcal{N}\left( A_i x_{N(i)}, \; D_i \right)

where:

  • A_i is a vector of regression coefficients

  • D_i is the conditional variance

These quantities are obtained from the covariance structure:

  • A_i = C_{i,N(i)} C_{N(i),N(i)}^{-1}

  • D_i = C_{i,i} - C_{i,N(i)} C_{N(i),N(i)}^{-1} C_{N(i),i}

where:

  • C_{N(i),N(i)} is the covariance matrix among neighbors

  • C_{i,N(i)} is the covariance between location i and its neighbors

The covariance structure is defined using an exponential covariance function.

These parameters are used to efficiently evaluate the NNGP likelihood and simulate from the process.

Value

A numeric matrix (M \times (k+1)) where:

  • First k columns: regression coefficients (A matrix)

  • Last column: conditional variances (D diagonal entries)

Author(s)

Fabian Ketwaroo

References

Finley, A. O., Datta, A., Cook, B. D., Morton, D. C., Andersen, H. E., & Banerjee, S. (2019). Efficient algorithms for Bayesian nearest neighbor Gaussian processes. *Journal of Computational and Graphical Statistics*, 28(2), 401–414. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1080/10618600.2018.1537924")}

Examples

coords <- matrix(runif(40), ncol = 2)
Nk = 5
res <- computeNeighbors(coords, k = Nk)
AD <- computeAD(edist = res$edist_sorted,
                nid.dist = res$neighbors_dist,
                neighbors.id = res$neighbor_idx,
                rho = 0.1,
                sigma2 = 0.3,
                k = Nk)


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