Documentation

6.13 Row and observation filters

Filters define the analysed population. They must be treated as analysis inputs, not terminal conveniences. nlmx has two related filter systems: $DATA IGNORE/ACCEPT in a control stream and R-style command filters.

$DATA IGNORE and ACCEPT

Control-stream filtering occurs before numeric model records are built. Conditions may reference dropped $INPUT positions. Multiple ACCEPT conditions act as alternatives: a row is retained when at least one accepts it, unless an IGNORE condition removes it.

Character and numeric comparison are distinct. .EQ./.NE. and == follow character-oriented comparison for $DATA conditions; .EQN./.NEN. request numeric equality/inequality. nlmx warns when tokens are numerically equal but character-unequal—for example, 1 versus 1.0—because that difference commonly explains a cross-software row-count mismatch.

R-style filters

Command filters support numeric/text comparisons, arithmetic, parentheses, logical &, | and !, membership with %in% c(...), and the same scalar functions used by mutate. Quoted values compare as text. Common forms are:

EVID == 0 & DVID == 1
SITE %in% c("A", "B") & WT >= 40
is.na(DV) | DV > 0
log(DV) > 1

Table 6.3. Expression grammar

Feature Forms
Arithmetic + - * / ^, unary signs, parentheses
Comparison == != < <= > >=
Logic &, `
Membership %in% c(value, ...)
Numeric functions log, log10, log2, exp, sqrt, abs, round, floor, ceiling, trunc, min/pmin, max/pmax
Conditional/missing ifelse(test, yes, no), is.na(x)
Text construction paste(...), paste0(...)

Functions are case-insensitive. log(x) is natural log; log(x, base) accepts a base. Invalid domains produce missing values in expression evaluation.

--filter versus --obs-filter

For dataset-oriented workflows such as EDA, a general filter tests rows. For autoinit and screen, --filter tests all rows, while --obs-filter tests observation rows and preserves dose rows. This distinction prevents an observation criterion such as DVID==1 from deleting the dose history.

VPC's --filter is subject-level: it tests the first record of each subject. ER uses row-level filtering. Always read the command-specific description; the same option spelling can intentionally have different scope.

The Chapter 6 EDA example mutates first, then applies EVID == 0 & DVID == 1. It retains 192 observation rows and no dose rows, so dose-dependent EDA panels are skipped. That is correct for the expression but illustrates why filters need a post-filter row-role summary.

Common mistakes

  • Using character equality when numeric equivalence was intended in $DATA.
  • Filtering observations and accidentally deleting all dose rows.
  • Assuming VPC filters individual rows.
  • Filtering on a derived column before it is created.
  • Recording only the expression and not retained row/subject counts.

Checklist

  • Character versus numeric $DATA comparison is intentional.
  • Filter scope is checked for the particular command.
  • Dose history remains when required.
  • Mutations occur before dependent filters.
  • Before/after rows, observations, doses and subjects are retained.

Further reading

Section 6.14 explains ordered derivation. Chapter 11 will show how qc-data audits filtered and unfiltered source quality.