covMat-methods {kergp} | R Documentation |
Covariance Matrix for a Covariance Kernel Object
Description
Covariance matrix for a covariance kernel object.
Usage
## S4 method for signature 'covMan'
covMat(object, X, Xnew, compGrad = hasGrad(object),
checkNames = NULL, index = 1L, ...)
## S4 method for signature 'covTS'
covMat(object, X, Xnew, compGrad = FALSE,
checkNames = TRUE, index = 1L, ...)
Arguments
object |
An object with S4 class corresponding to a covariance kernel. |
X |
The matrix (or data.frame) of design points, with |
Xnew |
An optional new matrix of spatial design points. If missing, the
same matrix is used: |
compGrad |
Logical. If |
checkNames |
Logical. If |
index |
Integer giving the index of the derivation parameter in the official
order. Ignored if |
... |
not used yet. |
Details
The covariance matrix is computed in a C program using the
.Call
interface. The R kernel function is evaluated within the
C code using eval
.
Value
A n_1 \times n_2
matrix with general element
C_{ij} :=
K(\mathbf{x}_{1,i},\,\mathbf{x}_{2,j};\,\boldsymbol{\theta})
where
K(\mathbf{x}_1,\,\mathbf{x}_2;\,\boldsymbol{\theta})
is the covariance kernel function.
Note
The value of the parameter \boldsymbol{\theta}
can be
extracted from the object with the coef
method.
Author(s)
Y. Deville, O. Roustant, D. Ginsbourger, N. Durrande.
See Also
coef
method
Examples
myCov <- covTS(inputs = c("Temp", "Humid", "Press"),
kernel = "k1PowExp",
dep = c(range = "cst", shape = "cst"),
value = c(shape = 1.8, range = 1.1))
n <- 100; X <- matrix(runif(n*3), nrow = n, ncol = 3)
try(C1 <- covMat(myCov, X)) ## bad colnames
colnames(X) <- inputNames(myCov)
C2 <- covMat(myCov, X)
Xnew <- matrix(runif(n * 3), nrow = n, ncol = 3)
colnames(Xnew) <- inputNames(myCov)
C2 <- covMat(myCov, X, Xnew)
## check with the same matrix in 'X' and 'Xnew'
CMM <- covMat(myCov, X, X)
CM <- covMat(myCov, X)
max(abs(CM - CMM))