testquadratic {scorematchingad}R Documentation

Test Whether a CppAD Tape is a Quadratic Function

Description

Uses the CppAD parameter property and derivatives (via tapeJacobian()) to test whether the tape is quadratic.

Usage

testquadratic(tape, xmat = NULL, dynparammat = NULL, verbose = FALSE)

Arguments

tape

An ADFun object.

xmat

If non-NULL and dynparamat non-NULL then the third-order derivatives at independent variable values of the rows of xmat and dynamic parameters from the rows of dynparammat are tested.

dynparammat

If non-NULL and xmat non-NULL then the third-order derivatives at independent variable values of the rows of xmat and dynamic parameters from the rows of dynparammat are tested.

verbose

If TRUE information about the failed tests is printed.

Details

Uses the xtape and dyntape values stored in tape to create new tapes. A tape of the Hessian is obtained by applying tapeJacobian() twice, and then uses a CppAD property to test whether the Hessian is constant. A function of quadratic form should have constant Hessian.

If xmat and dynparammat are non-NULL then testquadratic() also checks the Jacobian of the Hessian at xmat and dynparammat values. For quadratic form functions the Jacobian of the Hessian should be zero.

Value

TRUE or FALSE

See Also

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

Examples

tapes <- buildsmdtape(
   "sim", "sqrt", "sph",
   ll = "ppi",
   ytape = c(0.2, 0.3, 0.5),
   usertheta = ppi_paramvec(p = 3), 
   bdryw = "minsq",
   acut = 0.1,
   verbose = FALSE)

 testquadratic(tapes$smdtape)

[Package scorematchingad version 0.0.67 Index]