quadratictape_parts {scorematchingad}R Documentation

Evaluate the Hessian and Gradient Offset of a Taped Quadratic Function

Description

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.

Usage

quadratictape_parts(tape, tmat, tcentres = NA * tmat, approxorder = 10)

Arguments

tape

A tape of a quadratic function where the independent and dynamic parameters correspond to the x and t in the details section, respectively. For score matching tape should be a tape of the score matching discrepancy function A(z) + B(z) + C(z) in scorematchingtheory with z the dynamic parameters and the model parameters the independent variable (which is the usual for the return of buildsmdtape()).

tmat

A matrix of vectors corresponding to values of t (see details). Each row corresponds to a vector. For score matching, these vectors are measurements.

tcentres

A matrix of Taylor approximation centres for rows of tmat that require approximation. NA for rows that do not require approximation.

approxorder

The order of the Taylor approximation to use.

Details

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 tapeHessian() and tapeGradOffset() 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.

Value

A list of

See Also

Other tape evaluators: evaltape(), smvalues(), testquadratic()

Examples

u <- rep(1/3, 3)
smdtape <- buildsmdtape("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)))

[Package scorematchingad version 0.0.67 Index]