Learn R Programming

kergp (version 0.5.7)

varVec-methods: Covariance Matrix for a Covariance Kernel Object

Description

Covariance matrix for a covariance kernel object.

Usage

# S4 method for covMan
varVec(object, X, compGrad = FALSE, 
       checkNames = NULL, index = -1L, ...)

# S4 method for covTS varVec(object, X, compGrad = FALSE, checkNames = TRUE, index = -1L, ...)

Value

A vector of length nrow(X) with general element \(V_{i} := K(\mathbf{x}_{i},\,\mathbf{x}_{i};\,\boldsymbol{\theta})\) where

\(K(\mathbf{x}_1,\,\mathbf{x}_2;\,\boldsymbol{\theta})\) is the covariance kernel function.

Arguments

object

An object with S4 class corresponding to a covariance kernel.

X

The usual matrix of spatial design points, with \(n\) rows and \(d\) cols where \(n\) is the number of spatial points and \(d\) is the 'spatial' dimension.

compGrad

Logical. If TRUE a derivative with respect to the vector of parameters will be computed and returned as an attribute of the result. For the covMan class, this is possible only when the gradient of the kernel is computed and returned as a "gradient" attribute of the result.

checkNames

Logical. If TRUE (default), check the compatibility of X with object, see checkX.

index

Integer giving the index of the derivation parameter in the official order.

...

Not used yet.

Details

The variance vector is computed in a C program using the .Call interface. The R kernel function is evaluated within the C code using eval.

See Also

coef method

Examples

Run this code
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(V1 <- varVec(myCov, X = X)) ## bad colnames
colnames(X) <- inputNames(myCov)
V2 <- varVec(myCov, X = X)

Xnew <- matrix(runif(n * 3), nrow = n, ncol = 3)
colnames(Xnew) <- inputNames(myCov)
V2 <- varVec(myCov, X = X)

Run the code above in your browser using DataLab