|
3.3 Covariance Functions
Given below is a table of
covariance functions provided by the Fields software package:
Note that exp.cov is the default covariance function used if a
covariance function is not specified. Additionally, using p = 2 in exp.cov
is the Gaussian covariance function.
Before giving details on these covariances it is useful to outline the
basic form. The function test.cov in Fields can be used as a template for
building new covariance models. For example, it is possible to create a new
covariance function and use it with Krig to
estimate a surface. The basic form is
my.fun( x1, x2), where x1 and
x2 are matrices of locations with the rows being
the locations and the columns the individual coordinates for the location. The
covariance function should return a matrix. If
nrow( x1) = M, nrow( x2) = N, then my.fun( x1, x2)
should return an M x N cross covariance matrix whose (i, j)
element is the covariance between the ith row of
x1 with the jth row of x2. A handy
Fields function is rdist( x1, x2) which computes
the pairwise distance matrix between two sets of points--in this case
x1 and x2. For
example, the exponential/Gaussian covariance can be programmed as
my.cov <- function( x1, x2, p = 1, range=1) {
cov <- exp( - (rdist(x1, x2)/range)^p)
return( cov)
}
Then, to use this function with Krig, simply
include its name along with any parameters to be passed in. That is,
fit <- Krig( data$x, data$y, my.cov, range=12, p=1.5)
Back to top
Table - Covariance functions in Fields |
Name/ description | S-Function | optional arguments with defaults | Fortran/S version | C argument |
Exponential/ Gaussian | exp.cov | theta = 1, p = 1 | both | yes |
Exponential for sphere | exp.earth.cov | theta = 1 | S | no |
Matern | matern.cov | smoothness = 0.5 range = ?? | FORTRAN | no |
Periodic 1-d | periodic.cov.ld | a = 0, b = 1 | both | no |
Cylindrical | periodic.cov.cyl | a = 0, b = 365 theta = 1 | S | no |
Poisson covariance for the sphere | poisson.cov | eta = 0.2 | S | no |
Sample covariance | test.cov | theta = 1 | S | no |
Generalized spline covariance | rad.cov | p | both | yes |
|