matern_corr: Calculate a stationary Matern correlation matrix

Description Usage Arguments Value Examples

Description

matern_corr calculates a stationary Matern correlation matrix for a fixed set of locations, based on a range and smoothness parameter. This function is primarily used for the "npGP" and "approxGP" models. The function is coded as a nimbleFunction (see the nimble package) but can also be used as a regular R function.

Usage

1
matern_corr(dist, rho, nu)

Arguments

dist

N x N matrix; contains values of pairwise Euclidean distances in the x-y plane.

rho

Scalar; "range" parameter used to rescale distances

nu

Scalar; Matern smoothness parameter. nu = 0.5 corresponds to the Exponential correlation; nu = Inf corresponds to the Gaussian correlation function.

Value

A correlation matrix for a fixed set of stations and fixed parameter values.

Examples

1
2
3
4
5
6
7
# Generate some coordinates
coords <- cbind(runif(100),runif(100))
nu <- 2
# Calculate distances -- can use nsDist to calculate Euclidean distances
dist_list <- nsDist(coords, isotropic = TRUE)
# Calculate the correlation matrix
corMat <- matern_corr(sqrt(dist_list$dist1_sq), 1, nu)

BayesNSGP documentation built on Jan. 9, 2022, 9:07 a.m.