nsDist {BayesNSGP} | R Documentation |
Calculate coordinate-specific distance matrices
Description
nsDist
calculates x, y, and x-y distances for use in the
nonstationary correlation calculation. The sign of the cross-distance
is important. The function contains an optional argument for re-scaling
the distances such that the coordinates lie in a square.
Usage
nsDist(coords, scale_factor = NULL, isotropic = FALSE)
Arguments
coords |
N x 2 matrix; contains the x-y coordinates of stations |
scale_factor |
Scalar; optional argument for re-scaling the distances. |
isotropic |
Logical; indicates whether distances should be calculated
separately for each coordinate dimension (FALSE) or simultaneously for all
coordinate dimensions (TRUE). |
Value
A list of distances matrices, with the following components:
dist1_sq |
N x N matrix; contains values of pairwise squared distances in the x-coordinate. |
dist2_sq |
N x N matrix; contains values of pairwise squared distances in the y-coordinate. |
dist12 |
N x N matrix; contains values of pairwise signed cross- distances between the x- and y-coordinates. |
scale_factor |
Value of the scale factor used to rescale distances. |
Examples
# Generate some coordinates
coords <- cbind(runif(100),runif(100))
# Calculate distances
dist_list <- nsDist(coords)
# Use nsDist to calculate Euclidean distances
dist_Euclidean <- sqrt(nsDist(coords, isotropic = TRUE)$dist1_sq)