Learn R Programming

VeccTMVN (version 1.3.1)

find_nn_corr: Find ordered nearest neighbors based on a correlation Matrix. Assuming the absolute value of the correlation is monotonically decreasing with distance. Returns an n X (m + 1) matrix similar to `GpGp::find_ordered_nn`.

Description

Find ordered nearest neighbors based on a correlation Matrix. Assuming the absolute value of the correlation is monotonically decreasing with distance. Returns an n X (m + 1) matrix similar to `GpGp::find_ordered_nn`.

Usage

find_nn_corr(corrMat, m)

Value

an n X (m + 1) matrix

Arguments

corrMat

the correlation matrix

m

the number of nearest neighbors

Examples

Run this code
library(GpGp)
library(VeccTMVN)
set.seed(123)
d <- 3
n <- 100
locs <- matrix(runif(d * n), n, d)
covparms <- c(2, 0.01, 0)
cov_mat <- GpGp::matern15_isotropic(covparms, locs)
m <- 10
NNarray_test <- GpGp::find_ordered_nn(locs, m = m)
NNarray <- find_nn_corr(cov_mat, m)
cat("Number of mismatch is", sum(NNarray != NNarray_test, na.rm = TRUE))

Run the code above in your browser using DataLab