covarianceFactory | R Documentation |
A function factory which sets up a covariance function.
covarianceFactory(covariance, cov.args = list())
covariance |
A function which takes as input an object containing distances (h), a vector of parameters (theta), and a list of optional settings (cov.args) |
cov.args |
A list of optional settings for a covariance function. |
covarianceFactory()
is a function factory which takes as input an arbitrary covariance function and a list of additional arguments and returns a function with these arguments. The argument cov.args
mainly serves to pass the relevant arguments to the covariance function, but also allows users to specify the following two arguments:
NA
)A constant value for the range parameter. Note that the code assumes that the first value of theta
corresponds to the range parameter, as this notation is used in the spam package.
NA
)A constant value for the nugget parameter. Note that the code assumes that the last value of theta
corresponds to the nugget parameter, as this notation is used in the spam package.
Note that if either of these arguments are specified, the corresponding entries should also be omitted in theta
.
A function of the form function(h, theta)
. This function is enclosed in the execution environment of choleskyFactory
and hence has access to the arguments covariance
and cov.args
. The manufactured function returns the result of covariance(h = h, theta = theta, cov.args = cov.args)
.
Thomas Caspar Fischer
Wickham, H. (2015) Advanced R, CRC Press.
covmat
and
cov.wendland
library(GeneralizedWendland)
library(spam)
hs <- seq(0, 1, 0.05)
covSph <- covarianceFactory(cov.sph)
covExp <- covarianceFactory(cov.exp)
covWend <- covarianceFactory(cov.wendland)
plot(0, type = "n", xlim = c(0, 1), ylim = c(0, 1))
lines(hs, covSph(hs, theta = c(0.5, 1, 0)))
lines(hs, covExp(hs, theta = c(0.5, 1, 0)), col = "red")
lines(hs, covWend(hs, theta = c(0.5, 1, 0.5, 0.5, 0)), col = "green")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.