In d dimensions a process with Matern smoothness parameter S
will have S + d/2 derivatives that exist in a mean square sense. Functional Form: If x1 and x2 are matrices where nrow(x1)=m and nrow(
x2)=n then this
function should return a mXn matrix where the (i,j) element is the
covariance between the locations x1[i,] and x2[j,]. The
covariance is found as H( D.ij) where D.ij is the Euclidean
distance between x1[i,] and x2[j,] but having first been scaled by theta.
H is proportional to a modified Bessel function that depends on the
smoothness.
H is normalized so that H(0)=1.
Specifically the definition of the distance matrix is
D.ij = sqrt( sum.k (( x1[i,k] - x2[j,k]) /theta[k])**2 ).
Note that if theta is a scalar then this defines an isotropic covariance
function.
Implementation: The function rdist is a useful FIELDS function that finds
the cross
distance matrix ( D defined above) for two sets of locations. Thus in
compact S code we have
u <- t(t(x1)/theta)
v <- t(t(x2)/theta)
H(-rdist(u, v))
FORTRAN: The actual function calls FORTRAN to evaluate the special
function H (the FIELDS function matern). We
use the code by Montse Fuentes for this purpose.
A simple modification of this function for the user would be to substitute
rdist.earth for rdist to give a distance metric that makes sense for
lon/lat coordinates.