Computes the covariances for pairs variables, given the separation distance of their locations. Options for different correlation functions are available. The results can be seen as a change of metric, from the Euclidean distances to covariances.
cov.spatial(obj, cov.model= "matern",
cov.pars=stop("no cov.pars argument provided"),
kappa = 0.5)
The function returns values of the covariances corresponding to the
given distances.
The type of output is the same as the type of the object provided in the
argument obj
, typically a vector, matrix or array.
a numeric object (vector or matrix), typically with values of distances between pairs of spatial locations.
string indicating the type of the correlation
function. Available choices are: "matern", "exponential", "gaussian",
"spherical", "circular", "cubic", "wave",
"power", "powered.exponential", "cauchy", "gencauchy",
"gneiting", "gneiting.matern", "pure.nugget".
See section DETAILS
for available options and expressions of the correlation
functions.
a vector with 2 elements or an
numerical value for the additional smoothness parameter of the
correlation function.
Only required by the following correlation
functions: "matern"
, "powered.exponential"
,
"cauchy"
, "gencauchy"
and "gneiting.matern"
.
Paulo J. Ribeiro Jr. paulojus@leg.ufpr.br,
Peter J. Diggle p.diggle@lancaster.ac.uk.
Covariance functions return the value of the covariance
Denote besselK
for further details.
In the equations below the functions are valid for
cauchy
gencauchy (generalised Cauchy)
circular
Let
cubic
gaussian
exponential
matern
spherical
power (and linear)
The parameters of the this model
Since the corresponding process is not second order stationary the
covariance and correlation functions are not defined.
For internal calculations the geoR
functions uses the fact the this model possesses locally
stationary representations with covariance functions of the form:
The linear model corresponds a particular case with
powered.exponential (or stable)
gneiting
CovarianceFct
in the package
RandomFields
from where we extract the following :
It is an alternative to the gaussian
model since
its graph is visually hardly distinguishable from the graph of
the Gaussian model, but possesses neither the mathematical and nor the
numerical disadvantages of the Gaussian model.
gneiting.matern
Let
wave
pure.nugget
where k is a constant value. This model corresponds to
no spatial correlation.
Nested models
Models with several structures
usually called nested models
in the geostatistical literature are also allowed.
In this case the argument cov.pars
takes a matrix and
cov.model
and lambda
can either have length equal to
the number of rows of this matrix or length 1.
For the latter cov.model and/or lambda are recycled, i.e. the same
value is used for all structures.
For a review on correlation functions:
Schlather, M. (1999) An introduction to positive definite functions and to unconditional
simulation of random fields. Technical report ST 99-10, Dept. of Maths and Statistics,
Lancaster University.
Chilès, J.P. and Delfiner, P. (1999) Geostatistics: Modelling Spatial Uncertainty, Wiley.
Further information on the package geoR can be found at:
http://www.leg.ufpr.br/geoR/.
matern
for computation of the
besselK
for
computation of the Bessel function and
varcov.spatial
for computations related to the covariance matrix.
#
# Variogram models with the same "practical" range:
#
v.f <- function(x, ...){1-cov.spatial(x, ...)}
#
curve(v.f(x, cov.pars=c(1, .2)), from = 0, to = 1,
xlab = "distance", ylab = expression(gamma(h)),
main = "variograms with equivalent \"practical range\"")
curve(v.f(x, cov.pars = c(1, .6), cov.model = "sph"), 0, 1,
add = TRUE, lty = 2)
curve(v.f(x, cov.pars = c(1, .6/sqrt(3)), cov.model = "gau"),
0, 1, add = TRUE, lwd = 2)
legend("topleft", c("exponential", "spherical", "gaussian"),
lty=c(1,2,1), lwd=c(1,1,2))
#
# Matern models with equivalent "practical range"
# and varying smoothness parameter
#
curve(v.f(x, cov.pars = c(1, 0.25), kappa = 0.5),from = 0, to = 1,
xlab = "distance", ylab = expression(gamma(h)), lty = 2,
main = "models with equivalent \"practical\" range")
curve(v.f(x, cov.pars = c(1, 0.188), kappa = 1),from = 0, to = 1,
add = TRUE)
curve(v.f(x, cov.pars = c(1, 0.14), kappa = 2),from = 0, to = 1,
add = TRUE, lwd=2, lty=2)
curve(v.f(x, cov.pars = c(1, 0.117), kappa = 2),from = 0, to = 1,
add = TRUE, lwd=2)
legend("bottomright",
expression(list(kappa == 0.5, phi == 0.250),
list(kappa == 1, phi == 0.188), list(kappa == 2, phi == 0.140),
list(kappa == 3, phi == 0.117)), lty=c(2,1,2,1), lwd=c(1,1,2,2))
# plotting a nested variogram model
curve(v.f(x, cov.pars = rbind(c(.4, .2), c(.6,.3)),
cov.model = c("sph","exp")), 0, 1, ylab='nested model')
Run the code above in your browser using DataLab