Tutorials › Pharmacometric Workflows and Reproducible Modeling › Managing Candidate Model Versions

Run Management and Model Comparison · Tutorial 177 of 399

Managing Candidate Model Versions

Build a candidate-version workflow that makes each model state identifiable, its changes interpretable, and its relationship to other candidates explicit.

Intermediate 12 min read

What You'll Learn

  • Distinguish a model candidate version from a model run.
  • Design stable, unique identifiers for revisions and branches.
  • Record scientific changes separately from operational edits and input changes.
  • Create concise change records with parent links and artifact checks.
  • Detect common versioning failures such as overwriting and ambiguous labels.

Why Candidate Versions Need Their Own Records

A model-development project often has several plausible candidates at once: one may use a different absorption model, another may add a covariate, and a third may retain the same scientific specification while correcting a file path. If these states are identified only by informal names such as “final,” “new” or “best,” the team cannot reliably tell which model was intended for a particular analysis. The problem is not solved by recording only when a computational run occurred. A candidate is a defined model state; a run is an attempt to execute that state under a particular set of conditions.

Managing candidate versions means assigning each distinct model state an explicit, stable identifier and recording what changed from its parent. The record should allow a reviewer to answer, without relying on memory: What is this candidate? Which candidate did it derive from? Was the change scientific, operational, or related to the analysis inputs? Which exact model artifact does the identifier name?

Definition: A candidate model version is an identifiable, fixed model specification and its associated source artifacts at a point in development. A candidate version identifier is a unique label for that state, not for an execution of it. A change record states the parent version, the change made, its classification, and enough detail to distinguish the new state from its parent.

The earlier material on model version lineage establishes the value of recording relationships among model artifacts. Candidate management applies that idea to an active set of alternatives: each candidate receives an explicit version label, and every new revision has a traceable relationship to its predecessor or parent. An identifier should never be reassigned to a different state, even if the old state is no longer used.

A Practical Identity and Change-Record Rule

Use a readable identifier for people and a fingerprint or checksum of the relevant artifact for integrity checking. The label provides a stable handle; the fingerprint helps detect whether the files associated with that handle have changed. A checksum alone is usually a poor working label because it is difficult to read and does not explain the candidate’s place in the model-development sequence. Conversely, a descriptive label without an immutable artifact check can silently continue to name altered files.

A simple scheme can combine a candidate family name with a monotonically increasing revision, such as PK-A-v001 or PK-A-v002. When a candidate branches into distinct alternatives, give each branch its own family or branch label and record its parent. The names need not encode every scientific detail: the change record is where the details belong. Avoid using labels such as “final” as identifiers because the meaning of “final” changes as work continues.

Key rule: Each identifier must map to exactly one fixed candidate state. If a scientific specification or a file that defines that specification changes, create a new identifier. Preserve the old state and record the new state’s parent and change; do not edit the old version in place.

A concise change record is structured rather than a free-form note. It should include the version identifier, parent identifier (or “initial candidate”), date or revision time, change class, a brief description, the affected model component or artifact, and a reference to the exact stored artifact or its checksum. A short rationale can explain why the change was proposed. Keep the record concise enough to scan, but specific enough that “changed PK model” is not the only explanation.

Change classExamplesHow to record it
Scientific model changeAdding a transit absorption compartment; changing the random-effects structure; adding a prespecified covariate effectName the model component and describe the before-and-after specification
Operational editCorrecting a file path; changing a log filename; adjusting resource or output settings without changing the model specificationDescribe the edit and state why it is not intended to alter the scientific model
Input or analysis changeChanging the analysis dataset, exclusion rules, or data preparation that changes which observations enter the analysisRecord it separately from an operational edit; identify the affected input or rule

The classification is about the effect of an edit, not the person who made it or the file in which it appears. A one-line change can alter the scientific model, while a larger edit can be operational if it only reorganizes output. Changes to analysis inputs are called out separately because they can change the basis of an analysis even when the model code is unchanged. Do not label such a change “operational” merely because it was implemented in a data-processing script.

Why Immutable Identifiers Prevent Ambiguity

Consider two files both called “candidate-final.” If the second overwrites the first, the name no longer tells a reviewer which specification was used. Adding a date to a filename may reduce the chance of collision, but it still does not explicitly say whether the model changed, which earlier candidate it came from, or whether the contents were later edited. A reliable scheme therefore needs both an identifier that is never reused and a record of the parent-child relationship.

The design requirement can be stated precisely. Let \(S\) denote a fixed candidate state and \(I(S)\) its assigned identifier. The mapping must be one-to-one over the states being managed: if \(S_1\) and \(S_2\) differ in a model-defining way, then \(I(S_1)\) and \(I(S_2)\) must differ. A parent link then records the development relationship without pretending that the new candidate is merely another execution of the old one.

This gives a short justification for creating a new version whenever a model-defining artifact changes. If two distinct states share one identifier, a reviewer cannot determine which state that label denotes. If every distinct state receives a different identifier and the earlier artifact is preserved, the label and its record identify the intended state unambiguously. This does not establish that either candidate is scientifically appropriate; version control preserves what was proposed, not the validity of the proposal.

Worked Example: Separating a Scientific Change From a File Edit

Suppose a hypothetical project has candidate PK-A-v001, a one-compartment oral model with first-order absorption and a proportional residual-error model. A researcher proposes adding a transit absorption component. During implementation, the researcher also changes the output directory from “results-old” to “results-v2.” Determine how to version and document the changes.

The absorption change alters the scientific model specification, so it requires a new candidate version. Assign PK-A-v002, preserve PK-A-v001, and record PK-A-v001 as the parent. The change record should state that the absorption component changed from first-order absorption without transit compartments to a transit absorption component. It should identify the affected model artifact and include its stored location or checksum.

The output-directory change is operational if it only changes where files are written and does not change the model specification or analysis inputs. Record it as an operational edit, rather than describing it as part of the scientific rationale for the transit model. If the directory edit is made in the same saved artifact as the scientific change, note both changes in separate classified entries, or use separate revisions if the project needs to isolate their effects.

The record therefore distinguishes the two facts: the new candidate has a changed absorption model, and its execution configuration has a different output location. It does not imply that either change improved model fit or produced a successful run; those are separate records.

Recording Branches Without Losing Their Relationships

Competing candidates often arise by branching from a common parent rather than by changing one linear sequence. For example, a hypothetical parent PK-B-v003 may lead to one candidate that adds a weight covariate and another that changes the random-effects structure. Give each branch a unique identifier and name PK-B-v003 as the parent of both. Do not assign both branches the same next revision label, and do not describe one as a revision of the other unless it actually derives from it.

Worked Example: Documenting Two Competing Branches

Assume PK-B-v003 is a two-compartment model with interindividual variability on clearance and central volume. Two investigators propose separate changes. Investigator 1 adds a prespecified weight effect on clearance. Investigator 2 adds interindividual variability on peripheral volume, leaving the covariate specification unchanged.

Create two identifiers, for example PK-B-WT-v001 and PK-B-RV-v001. In both records, list PK-B-v003 as the parent. For PK-B-WT-v001, classify the change as scientific and state that weight was added as a covariate on clearance, including the precise functional form in the model artifact or its referenced specification. For PK-B-RV-v001, classify the change as scientific and state that interindividual variability was added to peripheral volume.

These records make the branch structure explicit. Neither new candidate is a child of the other, because each was developed from PK-B-v003. The identifiers distinguish the alternatives, while the change records say what differs. A label such as “PK-B-v004” for both branches would be ambiguous unless an additional unique branch component were included.

Change Records That Remain Useful

The purpose of a change record is not to reproduce the complete model code in prose. It is to summarize the meaningful delta and point to the immutable artifact that defines the candidate. A useful entry is brief but concrete: “Added a linear weight effect on clearance, centered at 70 kg; parent PK-B-v003; scientific change; model source fingerprint recorded.” An entry such as “updated covariates” is not enough to identify the change.

A practical record can use the following fields:

  • Identifier and parent: unique candidate label and the version from which it derives.
  • Change class: scientific model change, operational edit, or input/analysis change.
  • Change summary: a concise before-and-after description, naming the affected component.
  • Rationale: the reason for proposing the change, stated as a motivation rather than a claimed result.
  • Artifact reference: a stable location and, where available, a checksum or other integrity fingerprint.

If a revision contains changes from more than one class, keep the classes distinguishable in the record. If the purpose is to isolate one scientific change, make separate revisions for the operational adjustment and the scientific modification. This is especially helpful when an edit’s effect is uncertain: do not declare it operational solely because that was the intent. Record what changed, preserve the artifact, and flag uncertainty about whether it could alter the specification.

Worked Example: Classifying a Mixed Revision

A hypothetical team starts from PK-C-v005. It changes the dataset filter to exclude records with missing dose times, renames a log file, and corrects a typo in a comment. The model equations and parameter declarations are otherwise unchanged. Decide whether these edits belong in one new candidate record.

The filter change affects which observations enter the analysis, so it is an input or analysis change, not merely an operational edit. It requires a new recorded state and a clear description of the rule before and after the change. The log-file rename is operational if it affects only output naming. The comment correction is operational if it does not change executable model content.

A suitable record might use PK-C-v006 as a new version derived from PK-C-v005, with separate entries for the input change and operational edits. The record should identify the filter rule and the exact input or preparation artifact. If the team wants to evaluate the scientific model specification using unchanged inputs, it should not silently bundle the filter change into a candidate described only as a code cleanup. The candidate record identifies the full state; the classified entries make its components legible.

Diagnostics, Alternatives, and Limitations

Several warning signs indicate that candidate management is failing: two files have the same supposed version label; a change record says only “updated”; a branch has no stated parent; the recorded checksum does not match the stored artifact; or a model file is edited after its identifier has been assigned. These are not cosmetic defects. They prevent a team from establishing which specification a label denotes.

There are three common approaches. Overwriting a single “current model” file is quick but destroys prior states and makes the meaning of the filename depend on timing. Copying files into folders with informal labels preserves some history but makes parent relationships and change types hard to search. An immutable candidate registry with unique identifiers, parent links, concise change records, and artifact checks is more deliberate, but supports reliable retrieval and review. A version-control system can help preserve file history, but it does not by itself ensure that candidate labels, scientific rationales, input changes, and operational edits are documented in a way the modeling team can interpret.

Version records also have limits. They cannot guarantee that a model is correctly specified, that a change is scientifically justified, or that two candidates are suitable for a later statistical comparison. Nor do they replace records of execution conditions or run outcomes. Their narrower purpose is to keep candidate identities and changes explicit, so later work can refer to the intended model state without guessing.

Common Mistakes

  • Reusing an identifier. A label that once named one specification must not be assigned to a different one. Create a new revision instead.
  • Treating every code edit as operational. A small edit can change the likelihood, parameterization, data selection, or model assumptions. Classify by effect, not by line count.
  • Calling input changes operational. A changed filter or dataset can change the analysis basis. Record it separately from edits that only affect file handling.
  • Using “final” or “best” as a version. These are judgments that may change; they do not uniquely identify a fixed candidate state.
  • Recording only the change summary. Without a parent link and a reference to the exact artifact, a summary may not establish which state was changed or preserved.
Key takeaway: Give every distinct candidate state a unique, immutable identifier. Record its parent, classify each change by what it affects, and preserve a reference to the exact artifact. This makes competing model candidates distinguishable without confusing model identity with execution or analysis results.

Check Your Understanding

Answer each question, then compare with the brief solutions below.

  1. A candidate’s parameter estimates are unchanged, but its output filename is changed. What change class is appropriate, and should the edit be recorded?
  2. A model’s residual-error structure is changed from proportional to combined additive and proportional error. Should the existing candidate identifier be retained?
  3. Two alternatives are developed from the same parent: one adds a covariate and one changes the random-effects structure. How should their identifiers and parent links be recorded?
  4. A data-preparation rule excludes additional records, while the model source is unchanged. Why is it misleading to record this only as an operational edit?
  5. What does a checksum contribute, and why is it not a substitute for a readable candidate identifier and change record?

Solutions. (1) It is an operational edit if it affects only output naming, but it should still be recorded so the artifact state is clear. (2) No. The residual-error specification is scientific, so preserve the old state and assign a new identifier with the old candidate as parent. (3) Assign two distinct identifiers and record the common parent for both; each record describes its own scientific change. (4) The rule changes which observations enter the analysis, so it changes the analysis inputs and must be identified as such. (5) A checksum helps verify artifact integrity, but does not explain the candidate’s identity, parent, or reason for change; retain a readable identifier and structured record as well.

Clinical Biostats