Learn R Programming

scorematchingad (version 0.1.1)

testquadratic: Test Whether a CppAD Tape is a Quadratic Function

Description

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

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

Usage

testquadratic(
  tape,
  xmat = matrix(tape$xtape, nrow = 1),
  dynmat = matrix(tape$dyntape, nrow = 1),
  verbose = FALSE
)

Value

TRUE or FALSE

Arguments

tape

An ADFun object.

xmat

The third-order derivatives at independent variable values of the rows of xmat and dynamic parameters from the rows of dynmat are tested.

dynmat

The third-order derivatives at independent variable values of the rows of xmat and dynamic parameters from the rows of dynmat 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 tape_Jacobian() twice, and then uses the CppAD parameter property to test whether the Hessian is constant. A function of quadratic form should have constant Hessian.

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

See Also

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

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

Examples

Run this code
tapes <- tape_smd(
   "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)

Run the code above in your browser using DataLab