checkGrad {kergp} | R Documentation |
Check the Gradient Provided in a covMan
Object
Description
Check the gradient provided in a covMan
object.
Usage
checkGrad(object, sym = TRUE,
x1 = NULL, n1 = 10,
x2 = NULL, n2 = NULL,
XLower = NULL, XUpper = NULL,
plot = TRUE)
Arguments
object |
A |
sym |
Logical. If |
x1 |
Matrix to be used as the first argument of the kernel. |
n1 |
Number of rows for the matrix |
x2 |
Matrix to be used as the second argument of the kernel. |
n2 |
Number of rows for the matrix |
XLower |
Vector of lower bounds to draw |
XUpper |
Vector of upper bounds to draw |
plot |
|
Details
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.
Value
A list of results related to the Jacobians
test |
Max of the absolute difference between the gradient obtained by numeric differentiation and the gradient provided by the kernel object. |
Jnum , J |
Jacobians (arrays) computed
with |
x1 , x2 , K |
The matrices used
for the check, and the matrix of kernel values with
dimension |
Caution
For now the function only works when object
has class
"covMan"
.
Note
As a rule of thumb, a gradient coded without error gives a value of
test
less than 1e-4
, and usually the value is much
smaller than that.
Author(s)
Yves Deville