covmat: Covariance Functions

View source: R/covmat.R

covmatR Documentation

Covariance Functions

Description

Evaluate a covariance function.

Usage

covmat(h, theta, ... , type="sph")

cov.exp(h, theta, ... , eps= getOption("spam.eps"))
cov.sph(h, theta, ... , eps= getOption("spam.eps"))
cov.nug(h, theta, ... , eps= getOption("spam.eps"))
cov.wend1(h, theta, ... , eps= getOption("spam.eps"))
cov.wend2(h, theta, ... , eps= getOption("spam.eps"))
cov.wu1(h, theta, ... , eps= getOption("spam.eps"))
cov.wu2(h, theta, ... , eps= getOption("spam.eps"))
cov.wu3(h, theta, ... , eps= getOption("spam.eps"))
cov.mat(h, theta, ... , eps= getOption("spam.eps"))
cov.finnmat(h, theta, ... , eps= getOption("spam.eps"))
cov.mat12(h, theta, ... , eps= getOption("spam.eps"))
cov.mat32(h, theta, ... , eps= getOption("spam.eps"))
cov.mat52(h, theta, ... , eps= getOption("spam.eps"))

cor.sph(h, range, ... , eps= getOption("spam.eps"))

Arguments

h

object containing the lags.

theta

parameter of the covariance function, see ‘Details’.

range

parameter defining the compact support.

type

covariance function specification.

...

arguments passed from other methods.

eps

tolerance level, see ‘Details’.

Details

covmat is a wrapper that calls the other functions according to the argument type. The nomenclature is similar to precmat.
The parametrization is (range, [partial-sill = 1], [smoothness = 1], [nugget = 0]), where only the range needs to be specified. In case of negative parameter values, a warning is issued and the absolute value is retained. Although more cryptic, having all arguments as a single vector simplifies optimization with optim.
The parameters are and locations are up to precision epsilon. That means that all distances smaller than eps are considered zero; a nugget smaller than eps is ignored; a range smaller than eps represents a nugget model; etc.
cov.finnmat() is similar to cov.mat() but with the sqrt(8*smoothness)/range argument in the Bessel function (instead of 1/range). cov.mat12() is a wrapper to cov.exp() cov.mat32(), and cov.mat52() are fast version of cov.mat() with smoothness 3/2 and 5/2, respectively (factor 10).
cor.sph(,range) is a fast version of cov.sph(,c(range,1,0)).
Currently, the functions distinguish between a sparse spam object h and any other numeric type. In the future, this might change and appropriate methods will be implemented.

Value

Covariance function evaluated on h.

Author(s)

Reinhard Furrer

References

Any classical book about geostatistics.

See Also

precmat.

Examples

set.seed(123)
n <- 200
locs <- cbind(runif(n),runif(n))
h <- nearest.dist(locs, delta=sqrt(2), upper = NULL)
Sigma <- cov.sph(h, c(.3, 1, .1))

iidsample <- rnorm(n)
cholS <- chol.spam(as.spam(Sigma))
iorder <- iord <- ordering(cholS, inv = TRUE)
sample <- (iidsample %*% as.spam(cholS))[iorder]
plot(locs, col = fields::tim.colors(n = 256)[cut(sample, n)], pch = 20)

## Not run: 
h <- seq(0, to=1, length.out=100)
plot( h, cov.exp(h, c(1/3,1)), type='l', ylim=c(0,1))
type <- c("sph","wendland1","wendland2","wu1","wu2","wu3")
for (i in 1:6)
  lines( h, covmat(h, 1, type=type[i]), col=i+1)
legend('topright',legend=type, col=2:7, lty=1)


## End(Not run)

spam documentation built on Oct. 23, 2023, 5:07 p.m.