Learn R Programming

aghq (version 0.4.1)

validate_transformation: Validate a transformation object

Description

Routine for checking whether a given transformation is valid.

Usage

validate_transformation(...)

# S3 method for aghqtrans validate_transformation(trans, checkinverse = FALSE, ...)

# S3 method for list validate_transformation(translist, checkinverse = FALSE, ...)

# S3 method for default validate_transformation(...)

Value

TRUE if the function runs to completion without throwing an error.

Arguments

...

Used to pass arguments to methods.

trans

A transformation object of class aghqtrans returned by make_transformation.

checkinverse

Default FALSE, do not check that totheta(fromtheta(theta)) = theta. Otherwise, a vector of values for which to perform that check. No default values are provided, since validate_transformation has no way of determining the domain and range of totheta and fromtheta. This argument is used internally in aghq package functions, with cleverly chosen check values.

translist

A list. Will be checked, passed to aghqtrans, and then checked again.

Details

This function checks that:

  • The supplied object contains elements totheta, fromtheta, and jacobian, and that they are all functions,

  • If checkinverse is a vector of numbers, then it checks that totheta(fromtheta(checkinverse)) == checkinverse.

In addition, if a list is provided, the function first checks that it contains the right elements, then passes it to make_transformation, then checks that.

This function throws an informative error messages when checks don't pass or themselves throw errors.

See Also

Other transformations: default_transformation(), make_transformation()

Examples

Run this code

t <- make_transformation(log,exp)
validate_transformation(t)
t2 <- list(totheta = log,fromtheta = exp)
validate_transformation(t2)
if (FALSE) {
t3 <- make_transformation(log,log)
checkvals <- exp(exp(rnorm(10)))
# Should throw an informative error because log isn't the inverse of log.
validate_transformation(t3,checkinverse = checkvals)
}

Run the code above in your browser using DataLab