The function mkSpCov
calculates a spatial covariance matrix
given spatial locations and spatial covariance parameters.
1  mkSpCov(coords, K, Psi, theta, cov.model)

coords 
an nx2 matrix of the observation coordinates in R^2 (e.g., easting and northing). 
K 
the q x q spatial crosscovariance matrix. For a univariate model this corresponds to the partial sill, sigma^2. 
Psi 
the qxq nonspatial covariance matrix. For a univariate model this corresponds to the nugget, tau^2. 
theta 
a vector of q spatial decay parameters. If

cov.model 
a quoted keyword that specifies the covariance
function used to model the spatial dependence structure among the
observations. Supported covariance model key words are:

... 
currently no additional arguments. 
Covariance functions return the covariance C(h) between a pair locations separated by distance h. The covariance function can be written as a product of a variance parameter σ^2 and a positive definite correlation function ρ(h): C(h) = σ^2 * ρ(h), see, e.g., Banerjee et al. (2004) p. 27 for more details. The expressions of the correlations functions available in spBayes are given below. More will be added upon request.
For all correlations functions, phi is the spatial decay parameter.
Some of the correlation functions will have an extra parameter
nu, the smoothness parameter.
K_ν(x) denotes the modified Bessel
function of the third kind of order nu. See
documentation of the function besselK
for further details.
The following functions are valid for φ >
0 and ν > 0, unless stated otherwise.
gaussian
ρ(h) = exp((φ*h)^2)
exponential
ρ(h) = exp(φ*h)
matern
ρ(h) = (1/(2^(ν1) * Γ(ν))) * ((φ*h)^ν) * K_{ν}(φ*h)
spherical
ρ(h) = 1  1.5 * (φ*h) + 0.5*(φ*h)^3 if h < 1/φ , 0 otherwise
C 
the nqxnq spatial covariance matrix. 
Andrew O. Finley finleya@msu.edu,
Sudipto Banerjee baner009@umn.edu
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21  ## Not run:
##A bivariate spatial covariance matrix
n < 2 ##number of locations
q < 2 ##number of responses at each location
nltr < q*(q+1)/2 ##number of triangular elements in the crosscovariance matrix
coords < cbind(runif(n,0,1), runif(n,0,1))
##spatial decay parameters
theta < rep(6,q)
A < matrix(0,q,q)
A[lower.tri(A,TRUE)] < rnorm(nltr, 5, 1)
K < A%*%t(A)
Psi < diag(1,q)
C < mkSpCov(coords, K, Psi, theta, cov.model="exponential")
## End(Not run)

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.
All documentation is copyright its authors; we didn't write any of that.