Documentation

8.3 Expressions, operators and functions

The expression parser supports arithmetic, comparisons and logical operations with explicit precedence. From weakest to strongest, the implemented grouping is OR/EQV/NEQV, AND, NOT, relational, additive, multiplicative, unary and power. Power is right-associative.

This matters for model equivalence. Parenthesise expressions whose interpretation affects parameters rather than depending on remembered Fortran precedence.

Operators

Supported arithmetic operators are +, -, *, / and **. Comparisons include equality, inequality and ordered relations; dotted Fortran forms such as .EQ., .LE. and .GT. are accepted. Logical values are numeric: zero is false and nonzero is true.

Table 8.1. Built-in function families

Family Names
Exponential/log EXP, LOG, LOG10 and common D/A aliases
Roots/absolute SQRT, ABS
Trigonometric SIN, COS, TAN, ASIN, ACOS, ATAN
Hyperbolic SINH, COSH, TANH
Integer/rounding INT, NINT, aliases
Combination MOD, MIN, MAX, SIGN
Statistical PHI, GAMLN
Protected PEXP, PLOG, PLOG10, PSQRT, PDZ, PZR, PNP, PHE, PNGZ

MIN and MAX accept multiple arguments. OMEGA(i,j) and SIGMA(i,j) can be read by model code and are bound to variance-parameter values. Array indices are integer constants and are one-based in control-stream syntax.

Differentiability

Smooth functions propagate dual-number derivatives. Comparisons, branch selection, integer functions and min/max create piecewise behavior. At a discontinuity or tie, the value may be well defined while a derivative is one-sided, zeroed or branch-dependent. Such models need boundary-specific tests.

Protected functions trade exact mathematical behavior outside safe domains for finite evaluation. Cross-software tests must align protection rules, not only the visible formula.

Common mistakes

  • Assuming -A**2 and (-A)**2 are equivalent.
  • Comparing protected and unprotected functions at extreme values.
  • Expecting a smooth derivative through a data-driven branch boundary.

Checklist

  • Parenthesise critical formulas.
  • Inventory every function against the supported list.
  • Test values and derivatives near piecewise boundaries.

Further reading

See automatic differentiation, likelihood evaluation and accuracy boundaries.