View source: R/quadratictape_parts.R
quadratictape_parts | R Documentation |
When the score matching discrepancy function is quadratic then the gradient of the score matching discrepancy function can be written using the Hessian and an offset term. This can be useful for solving for the situation when the gradient is zero.
The Hessian and offset term are computed using CppAD
tapes.
Taylor approximation can be used for locations at removed singularities (i.e. where intermediate values are unbounded).
quadratictape_parts()
will error if testquadratic(tape)
returns FALSE
.
quadratictape_parts(tape, tmat, tcentres = NA * tmat, approxorder = 10)
tape |
A tape of a quadratic function where the independent and dynamic parameters correspond to the |
tmat |
A matrix of vectors corresponding to values of |
tcentres |
A matrix of Taylor approximation centres for rows of |
approxorder |
The order of the Taylor approximation to use. |
A quadratic function can be written
f(x; t) = \frac{1}{2} x^T W(t) x + b(t)^T x + c,
where t
is considered a vector that is constant with respect to the differentiation.
The Hessian of the function is with respect to x
is
H f(x; t) = \frac{1}{2}(W(t) + W(t)^T).
The gradient of the function with respect to x
can then be written
\Delta f(x;t) = H f(x; t) x + b(t)^T x,
where the Hessian and offset b(t)
depend only on t
.
The functions here evaluate the Hessian and offset b(t)
for many values of t
.
Tapes of the Hessian and gradient offset are created using tape_Hessian()
and tape_gradoffset()
respectively.
These tapes are then evaluated for every row of tmat
.
When the corresponding tcentres
row is not NA
, then approximate (but very accurate) results are calculated using Taylor approximation around the location given by the row of tcentres
.
For score matching x
is the set of model parameters and the vector t
is a (multivariate) measurement.
A list of
offset
Array of offsets b(t)
, each row corresponding to a row in tmat
Hessian
Array of vectorised H f(x; t)
(see tape_Hessian()
), each row corresponding to a row in tmat
. For each row, obtain the Hessian in matrix format by using matrix(ncol = length(tape$xtape))
.
Other tape evaluators:
evaltape()
,
smvalues()
,
testquadratic()
u <- rep(1/3, 3)
smdtape <- tape_smd("sim", "sqrt", "sph", "ppi",
ytape = u,
usertheta = ppi_paramvec(p = 3),
bdryw = "minsq", acut = 0.01,
verbose = FALSE
)$smdtape
quadratictape_parts(smdtape,
tmat = rbind(u, c(1/4, 1/4, 1/2)))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.