Learn R Programming

RandomFields (version 3.1.16)

RFcov: Evaluate Covariance and Variogram Functions

Description

RFcov returns the values of a covariance function; RFvariogram returns the values of a variogram; RFpseudovariogram returns the values of a pseudovariogram; RFcovmatrix returns the covariance matrix for a set of points RFfctn returns the values of a shape function;

Usage

RFcov(model, x, y = NULL, z = NULL, T = NULL, grid, distances, dim, ...)
RFvariogram(model, x, y = NULL, z = NULL, T = NULL, grid, distances, dim, ...)
RFpseudovariogram(model, x, y = NULL, z = NULL, T = NULL, grid, distances, dim, ...)
RFcovmatrix(model, x, y = NULL, z = NULL, T = NULL, grid, distances, dim,...)
RFfctn(model, x, y = NULL, z = NULL, T = NULL, grid, distances, dim,...)

Arguments

model
object of class RMmodel; the covariance or variogram model, which is to be evaluated
x
vector or $(n x \code{dim})$-matrix, where $n$ is the number of points at which the covariance function is to be evaluated; in particular, if the model is isotropic or dim=1 then x is a vector. x
y
second vector or matrix for non-stationary covariance functions
z
z-component of point if xyzT-specification of points is used
T
T-component of point if xyzT-specification of points is used
grid
boolean; whether xyzT specify a grid
distances
vector; only if the function RFcovmatrix is used; the lower triangular part of the distance matrix column-wise; equivalently the upper triangular part of the distance matrix row-wise; either x or distances must be missing
dim
dimension of the coordinate space in which the model is applied
...
arguments passed to RFcov (RFcovmatrix) and arguments passed to RFoptions

Value

RFcov returns a vector of values of the covariance function.RFvariogram returns a vector of values of the variogram model.RFpseudovariogram returns a vector of values of the variogram model.RFcovmatrix returns a covariance matrix.

Details

RFcovmatrix returns a covariance matrix. Here a matrix of of coordinates (x) or a vector or a matrix of distances is expected. RFcovmatrix allows also for variogram models. Then the negative of the variogram matrix is returned.

See Also

RMmodel, RFsimulate, RFfit. RFcalc.

Examples

Run this code
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set
##                   RFoptions(seed=NA) to make them all random again

# locations:
x <- matrix(runif(15), ncol=3)
 # coordinate matrix of 5 arbitrary points
 # p1, p2, p3, p4, p5 in 3-dimensional space
y <- matrix(runif(15),ncol=3)
 # coordinate matrix of 5 arbitrary points
 # q1, q2, q3, q4, q5 in 3-dimensional space


#####################################################
# get available models
RFgetModelNames(type=c("tail correlation", "positive definite",
               "variogram", "shape function", "trend"))

#####################################################
# Example 1: a stationary covariance model

model <- RMexp()

# covariance only depends on differences
# of locations hi=pi-qi in 3-dimensional space
# therefore, the following 2 commands yield the same

RFcov(model=model, x=x, y=y)
RFcov(model=model, x=x-y)
 # yields 5 values C(hi)=C(pi,qi) for i=1,2,3,4,5



##################################################
# Example 2: get covariance matrix C(x_i,x_j)    
# at given locations x_i, i=1,...,n 
#
# here for an isotropic stationary covariance model
# yields a 4 times 4 covariance matrix of the form
# C(0)   C(5)   C(3)   C(2.5)
# C(5)   C(0)   C(4)   C(2.5)
# C(3)   C(4)   C(0)   C(2.5)
# C(2.5) C(2.5) C(2.5) C(0)

model <- RMexp() # the covariance function C(x,y)=C(r) of this model
#                  depends only on the distance r between x and y
RFcovmatrix(model=model, distances=c(5,3,2.5,4,2.5,2.5), dim=4)



######################################################
# Example 3: distinguish the different uses of x and y

x <- c(1,2,1)
y <- c(4,5,6)

# coordinate space 1-dimensional, evaluated at 3 points:
RFcov(model=model, x=as.matrix(x), y=as.matrix(y))
# coordinate space is 3-dimensional, evaluated at a pair of points
RFcov(model=model, x=t(x), y=t(y))





Run the code above in your browser using DataLab