omxCheckWithinPercentError: Approximate Percent Equality Testing Function

Description Usage Arguments Details References See Also Examples

View source: R/MxUnitTesting.R

Description

This function tests whether two numeric vectors or matrixes are approximately equal to one another, within a specified percentage.

Usage

1
omxCheckWithinPercentError(a, b, percent = 0.1)

Arguments

a

a numeric vector or matrix.

b

a numeric vector or matrix.

percent

a non-negative percentage.

Details

Arguments ‘a’ and ‘b’ must be of the same type, ie. they must be either vectors of equal dimension or matrices of equal dimension. The two arguments are compared element-wise for approximate equality. If the absolute value of the difference of any two values is greater than the percentage difference of ‘a’, then an error will be thrown. If ‘a’ and ‘b’ are approximately equal to each other, by default the function will print a statement informing the user the test has passed. To turn off these print statements use options("mxPrintUnitTests" = FALSE).

References

The OpenMx User's guide can be found at http://openmx.ssri.psu.edu/documentation.

See Also

omxCheckCloseEnough, omxCheckIdentical, omxCheckSetEquals, omxCheckTrue, omxCheckEquals

Examples

1
2
3
4
5
6
omxCheckWithinPercentError(c(1, 2, 3), c(1.1, 1.9 ,3.0), percent = 50)

omxCheckWithinPercentError(matrix(3, 3, 3), matrix(4, 3, 3), percent = 150)

# Throws an error
try(omxCheckWithinPercentError(c(1, 2, 3), c(1.1, 1.9 ,3.0), percent = 0.01))

OpenMx documentation built on Aug. 6, 2018, 5:03 p.m.