Tutorials › Multiple Imputation by Chained Equations (MICE) › Releasing Code and Supporting Materials

Software, Reporting and Pitfalls · Tutorial 493 of 497

Releasing Code and Supporting Materials

Build a self-contained, documented release that lets others inspect and run the MICE workflow without exposing data they are not permitted to access.

Intermediate 11 min read

What You'll Learn

  • Identify the essential components of a reproducibility package for a MICE analysis.
  • Organize scripts, configuration, documentation, and example data so the workflow can be run from a clean copy.
  • Distinguish a faithful reproduction from an executable demonstration using synthetic or permitted data.
  • Specify dependencies, execution steps, and checks that help users identify mismatches.
  • Recognize why a seed alone does not guarantee identical results across software environments.

Why Release a Reproducibility Package?

A report may explain which variables were imputed and how results were summarized, yet still leave a reader unable to run the analysis. The executable workflow can depend on a particular sequence of scripts, configuration choices, software versions, input-data layout, and random-number settings. A reproducibility package brings these materials together so another person can inspect the analysis and, where authorized data are available, run it.

The aim is not simply to publish a folder of code. The package should make clear what to run, what inputs are expected, what outputs should appear, and which results can be checked. It should also be honest about what a user can reproduce when the original analysis data cannot be distributed. Code can be made executable without implying that a demonstration on replacement data recreates the original findings.

Definition: A reproducibility package is an organized set of permitted scripts, configuration, documentation, software-environment information, and any permitted input or example data needed to execute or inspect a reported computational workflow. Its contents and instructions should identify which results can be reproduced with the included materials and which require data or resources not included in the release.

What Belongs in a MICE Release?

A useful package usually separates analysis code from settings and data. The exact file names are flexible; the reader should not have to guess which script is the entry point or silently supply undocumented settings. A compact project might contain the following:

  • Scripts: an entry-point script and the supporting functions it calls, including steps for input checks, the MICE run, analysis, and saved outputs.
  • Configuration: explicit choices such as variable roles, predictor settings, number of imputations and iterations, random-number seed, and output locations. Settings should be visible rather than scattered among hidden defaults.
  • Documentation: a README with prerequisites and ordered run instructions, a description of expected inputs and outputs, and a note about which data are included or unavailable.
  • Environment information: software and package versions, plus a dependency specification or lock file when practical. A version list is useful, but it is not by itself a guarantee that every platform will behave identically.
  • Data or fixtures: only data that may be distributed, such as a permitted public dataset, a small teaching example, or carefully designed synthetic data. Include a description of its purpose and limitations.
  • Checks and expected outputs: lightweight checks that confirm the workflow ran as intended, such as dimensions, required variables, completed-dataset counts, and comparison values or summaries appropriate to the example.

A clear directory structure reduces ambiguity. For example, a package might use scripts/ for executable files, config/ for settings, data-example/ for permitted demonstration inputs, outputs-example/ for small expected outputs, and README for instructions. Keep generated files out of source-data folders and explain whether users should expect the scripts to overwrite outputs.

State assumptions about the execution environment before giving run instructions. For example, users may need a specified version of R, installed packages, permission to write to an output directory, and either an included input file or access to a separately authorized data source. The instructions should begin from a clean copy of the release rather than rely on files left over from the developer’s machine.

Worked Example: Checking Package Completeness

Suppose a hypothetical team plans to release a MICE analysis package. Before release, it defines six required items: an entry-point script, a configuration file, a helper script, a README, an environment specification, and a permitted example input. The release candidate contains five of these; the environment specification is missing.

A simple completeness measure is the number of required items present divided by the number required:

$$ \text{completeness}=\frac{\text{required items present}}{\text{required items}} =\frac{5}{6}=0.8333 $$

Thus, the release candidate contains 83.33% of its declared required items. This is a checklist measure, not a statistical quality score: a missing environment specification may matter more than a missing optional plot. Here it is a release blocker because users cannot see the tested software dependencies. The team adds that file, verifies that all six items are present, and gives the README the exact entry-point command and expected output location.

The check is meaningful only because the team defined the required items in advance and checked the actual release candidate, not merely the working directory. It should also verify that referenced files exist and that the documented paths match the package.

Make the Workflow Executable, Not Merely Visible

Instructions should describe a sequence that a reader can follow without relying on undocumented local state. In a typical release, the README identifies prerequisites, how to install or restore dependencies, where to place authorized input data, the command that starts the workflow, and how to inspect its outputs. Paths should be relative to the project where possible. Configuration should state important choices explicitly, including those that might otherwise be set by a software default.

The workflow also needs checks that distinguish successful execution from a plausible-looking but incomplete output. For example, the package can check that required variables are present, that the expected number of completed datasets was produced, and that saved result files are nonempty. These checks do not establish that the imputation model is scientifically appropriate; they establish that specified computational steps ran and produced structurally expected results.

A useful way to reason about execution is to represent the output as a function of its inputs and computational settings. Let \(Y\) denote an output, \(D\) the input data, \(C\) the code, \(K\) the configuration, \(E\) the software environment, and \(R\) the random-number state.

$$ Y = F(D,C,K,E,R) $$

This expression is a bookkeeping model, not a claim that every program is mathematically deterministic. It highlights why omitting any component weakens reproducibility: without the code or settings, the same input may be processed differently; without the required input, a user cannot recreate the same run; and different environments can change algorithms or numerical results. A seed helps define \(R\), but it does not generally fix \(D\), \(C\), \(K\), or \(E\).

Worked Example: Demonstrating Execution Without Original Data

A hypothetical clinical team cannot distribute its original patient records. It can, however, release the analysis scripts and configuration, together with a synthetic dataset of 120 rows and four variables: a continuous outcome, an age-like predictor, a binary indicator, and a partially missing auxiliary variable. The data are generated for demonstration and are not derived from patient records.

The README states that the example has 120 rows, that the binary indicator has two permitted levels, and that the auxiliary variable contains 24 missing values. The missingness proportion for that variable is:

$$ \frac{24}{120}=0.20 $$

So 20% of the example values for that variable are missing. The entry-point script checks these declared dimensions and missingness, runs the configured MICE workflow, and saves a small set of example outputs. A reader can therefore test whether the package installs, executes, and produces the expected output structure.

The team must label the result correctly: the synthetic-data run demonstrates execution, not reproduction of the analysis estimates from the unavailable patient records. The scripts and settings may be identical, but \(D\) differs in \(Y=F(D,C,K,E,R)\); therefore, the resulting imputations and estimates need not match. The package should not present the synthetic output as if it were an estimate from the original analysis.

When Original Data Cannot Be Included

If original data cannot be distributed, an executable release can still be useful. It can include code, configuration, documentation, dependency information, and a permitted example input. If appropriate, it can also describe the required input schema and explain how an authorized user can provide the original data through an approved route. The public example should be sufficient to exercise the code path, but it need not reproduce the original data distribution or scientific findings.

Be precise about the release’s level of reproducibility. Useful distinctions include:

  • Code inspection: readers can examine the scripts and settings, but cannot run the full analysis using the required original input.
  • Execution demonstration: readers can run the workflow on included permitted example data and confirm that the software produces outputs.
  • Analysis reproduction: an authorized user with the required original data and specified environment can run the analysis and compare its outputs with reported results.

These are different claims. A successful example-data run does not establish agreement with the original analysis, while a package requiring authorized data can still make the computational workflow transparent and executable for authorized users. State limitations plainly. Do not imply that a synthetic dataset is the original dataset, or that it preserves all properties relevant to the analysis.

Worked Example: Interpreting an Output Check

Suppose a hypothetical package includes a permitted fixture with a documented expected summary value of 1.200 units. A test run returns 1.203 units. The README specifies an absolute tolerance of 0.010 units for this check, so the comparison is:

$$ |1.203-1.200|=0.003\text{ units}<0.010\text{ units} $$

The test passes because the observed difference, 0.003 units, is smaller than the prespecified tolerance, 0.010 units. This supports the limited conclusion that the fixture-based computation agrees with its expected summary within the stated tolerance. It does not show that the original-data analysis has been reproduced, nor does it validate the scientific model.

A tolerance is appropriate when exact numerical equality is not a reasonable expectation, for example because of floating-point arithmetic or documented variation across supported environments. The test should identify the quantity, units, expected value, and tolerance. Choosing a tolerance only after seeing a discrepancy would make the check difficult to interpret.

Seeds, Versions, and Diagnostics

MICE uses random-number generation, so setting and documenting a seed is important for repeatable execution in a specified setting. However, a seed is not a universal reproducibility guarantee. Results can change if the software version, random-number generator, algorithms, data order, or other relevant settings differ. State the environment in which the reference outputs were generated, and avoid promising bit-for-bit equality unless it has been tested and is a realistic requirement.

Diagnostics for the release itself include whether the documented command runs from a clean copy, whether all referenced files are present, whether the expected outputs are created, and whether key checks produce the documented results. A failed package check can reveal missing dependencies, stale paths, reliance on local files, or an example dataset that does not meet the stated schema. Record enough information to diagnose such failures; a log should not silently substitute for the source inputs or configuration.

A package check is not a substitute for substantive statistical review. Successful execution cannot establish that the analysis choices are justified, that the assumptions are adequate, or that a result is robust. Those conclusions require their own statistical assessment. The release’s job is to make the implemented workflow inspectable and, within its stated limits, executable.

Common Pitfalls and Practical Trade-offs

  • Including code but no run instructions. A directory of scripts is not a usable release if readers cannot tell which script to run or what inputs it expects. Identify an entry point and give ordered, clean-start instructions.
  • Relying on hidden defaults. A run may depend on settings not visible in the release. Record the important configuration and identify software defaults that matter to the analysis.
  • Calling an example run a reproduction. If the included input differs from the original, the output is a demonstration on that input. Describe the distinction explicitly.
  • Assuming the seed fixes every difference. A seed controls only part of the computational setup. Document versions and settings, and test the package in the environments you claim to support.
  • Adding unpermitted data for convenience. Include data only when distribution is authorized. If that is not possible, provide a permitted example and clear instructions about the required input, without suggesting users should bypass access restrictions.
  • Testing only on the developer’s machine. Local files, cached dependencies, or existing outputs can hide missing package components. Test from a clean copy and check that the documented run path works.

There is a practical balance between a minimal package and a highly controlled computational environment. A small package is easier to inspect and maintain, but may leave some dependency uncertainty. A more constrained environment can improve consistency, but can take more effort to install and may be platform-specific. State the trade-off rather than treating one packaging choice as universally best.

Key takeaway: Release the materials needed to inspect and execute the workflow, make every input and limitation explicit, and distinguish a permitted-data demonstration from reproduction of results based on unavailable original data.

Check Your Understanding

Answer each question, then compare your reasoning with the solutions.

  1. A package includes scripts and a seed, but no dependency information or run instructions. Name two reasons that another user may not be able to reproduce its execution.
  2. A synthetic example has 200 rows and 30 missing values in one variable. What proportion of that variable’s values are missing?
  3. A user runs the released workflow on synthetic data and obtains different estimates from the report based on unavailable original data. Does this establish a package failure? Explain.
  4. A fixture test has expected value 4.50 units, observed value 4.494 units, and tolerance 0.010 units. Does the check pass?
  5. State one useful claim an example-data run can support and one claim it cannot support by itself.

Solutions. (1) Without dependency information, software versions or required packages may differ; without run instructions, the user may not know the entry point, required inputs, or expected outputs. (2) The missing proportion is \(30/200=0.15\), or 15%. (3) Not by itself. The data differ, so the run demonstrates execution on the synthetic input rather than reproduction of estimates from the original input; the package may still be working as intended. (4) Yes. The absolute difference is \(|4.494-4.50|=0.006\) units, and \(0.006<0.010\). (5) It can support the claim that the released code executes on the included example and produces expected structural outputs. It cannot, by itself, establish that results from unavailable original data have been reproduced.

Clinical Biostats