covMan ObjectCheck the gradient provided in a covMan object.
checkGrad(object, sym = TRUE,
x1 = NULL, n1 = 10,
x2 = NULL, n2 = NULL,
XLower = NULL, XUpper = NULL,
plot = TRUE)A list of results related to the Jacobians
testMax of the absolute difference between the gradient obtained by numeric differentiation and the gradient provided by the kernel object.
Jnum, JJacobians (arrays) computed
with numDeriv::jacobian and provided by the kernel
object.
x1, x2, KThe matrices used
for the check, and the matrix of kernel values with
dimension c(n1, n2). The element x2 can be
NULL if the determination of the matrix x2
was not necessary.
A covMan object.
Logical. If TRUE, the check is done assuming that x2
is identical to x1, so the provided values for x2 and
n2 (if any) will be ignored.
Matrix to be used as the first argument of the kernel.
Number of rows for the matrix x1. Used only when x1 is
not provided.
Matrix to be used as the second argument of the kernel.
Number of rows for the matrix x2. Used only when x2 is
not provided.
Vector of lower bounds to draw x1 and x2 when needed.
Vector of upper bounds to draw x1 and x2 when needed.
Logical. If TRUE, a plot is shown comparing the two
arrays of gradients.
For now the function only works when object has class
"covMan".
Yves Deville
Each of the two matrices x1 and x2 with n1 and
n2 rows can be given or instead be drawn at random. The matrix
of kernel values with dimension c(n1, n2) is computed, together
with its gradient with dimension c(n1, n2, npar) where
npar is the number of parameters of the kernel. A numerical
differentiation w.r.t. the kernel parameters is performed for the
kernel value at x1 and x2, and the result is compared to
that provided by the kernel function (the function described in the
slot named "kernel" of object). Note that the value of
the parameter vector is the value provided by coef(object) and
it can be changed by using the replacement method `coef<-` if
needed.