| dmnorm_NN_GP | R Documentation |
Evaluates the log-density of a multivariate normal distribution under the Nearest-Neighbor Gaussian Process (NNGP) approximation as defined by Data et al 2016.
dmnorm_NN_GP(x, mu, AD, neighbors.id, log = 1)
x |
Numeric vector (length |
mu |
Numeric vector (length |
AD |
Numeric matrix (
|
neighbors.id |
Integer matrix ( |
log |
Logical/Integer. If |
The NNGP approximation factorizes the joint density as:
p(\mathbf{x}) \approx \prod_{i=1}^M p(x_i \mid x_{N(i)})
leading to the log-density:
-\frac{1}{2} \left( N \log(2\pi) + \sum_i \log D_i + Q \right)
where:
D_i are conditional variances
Q is the quadratic form computed by computeQF
The quadratic form corresponds to:
Q = \sum_{i=1}^M \frac{(x_i - \mu_i - A_i(x_{N(i)} - \mu_{N(i)}))^2}{D_i}
This formulation avoids constructing the sparse covariance matrix, enabling scalable likelihood evaluation for large spatial datasets.
A scalar value corresponding to the (log-)density.
Fabian Ketwaroo
Datta, A., Banerjee, S., Finley, A.O. and Gelfand, A.E., 2016. Hierarchical nearest-neighbor Gaussian process models for large geostatistical datasets. *Journal of the American Statistical Association*, 111(514), 800-812. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1080/01621459.2015.1044091")}
M <- 2000 # number of spatial locations
coords <- matrix(runif(2*M), ncol = 2)
Nk <- 15 # number of neighbors
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)
w <- rmnorm_NN_GP(n = 1, mu = rep(0, M),
AD = AD[1:M, 1:(Nk+1)],
neighbors.id = res$neighbor_idx[1:M, 1:Nk])
loglike <- dmnorm_NN_GP(w, mu = rep(0, M),
AD = AD[1:M, 1:(Nk+1)],
neighbors.id = res$neighbor_idx[1:M, 1:Nk],
log = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.