Why Provenance Matters for Imputation
A MICE analysis depends on the data that entered preprocessing and on the choices made before imputation. If a source file is overwritten, replaced by a similarly named file, or changed during a transfer, a later analyst may be unable to determine which data produced a reported result. A project can have orderly scripts and still lack a reliable answer to that question.
The earlier material on Structuring a Reproducible MICE Project provides the broader project structure. Here the focus is narrower: preserve the original files, record their origins and relevant dates, and connect each imputation run to the exact input-file contents. This is an operational safeguard, not a statistical method; it does not establish that the data are accurate or that the imputation model is appropriate.
Keep Source Files Separate From Analysis Files
Treat a file received from a data provider, repository, or colleague as a source artifact. Preserve it unchanged in a designated raw-data location, preferably one that ordinary analysis scripts cannot overwrite. Do not use that copy as a scratch file: import it, then write any cleaned or transformed data to a separate location. The resulting directory structure might distinguish raw, intermediate, and analysis-ready files. The exact names are less important than maintaining a clear boundary between the source and its descendants.
“Unchanged” has a practical meaning: do not edit, resave, rename in a way that loses identity, or replace the preserved source file. If a provider sends a corrected file, retain both versions as separate artifacts and record which one supersedes the other. Record the original file name as received, even if a stable project file name is also assigned. Preserve an independent backup when feasible; a checksum can reveal that a file changed, but it cannot restore the original bytes.
For each source file, record its origin and the date it was obtained. Also record the modification date reported by the source, if available, and the file size. These are different facts. An acquisition date describes when your project received or accessed the file; a modification date may describe a timestamp set by the provider or file system. Copying, downloading, or archiving a file can alter file-system timestamps, so a date alone does not identify file contents.
Make a File Manifest
A manifest is a compact, human-readable record of the files associated with a project or run. For each input, include enough information to locate it and check its identity. A useful record includes the project-relative path, source name, origin, acquisition date, source-reported modification date if known, size in bytes, checksum algorithm, and checksum value. Note unknown information as unknown rather than guessing.
Use a cryptographic hash over the exact file bytes. For example, SHA-256 produces a 256-bit digest, usually written as 64 hexadecimal characters. The digest is not a summary of the file's statistical content: two files with the same rows but different encoding or line endings can have different digests. That is expected, because the files are not byte-for-byte identical.
This notation expresses the checksum operation, not a statistical model. Its practical value relies on the hash algorithm being deterministic and collision-resistant: for distinct files, a matching digest is extraordinarily unlikely under ordinary use, but not logically impossible. A digest should therefore be used to check identity, not treated as proof of origin, accuracy, or authenticity. If an attacker can replace both a file and its manifest, an unsigned manifest alone does not protect against that deliberate change.
Worked Example: Recording a Source File
Suppose a hypothetical data center provides clinic_export.csv on 14 October 2026. The file is 18,432 bytes. Its accompanying transfer note says that the export was generated on 12 October 2026. The project computes a SHA-256 digest and records the illustrative value 8a1f…c904; the shortened value here is only for display, not a complete digest.
The manifest should distinguish the dates: acquisition date, 14 October 2026; provider-reported generation date, 12 October 2026. It should record the received name, source, file size of 18,432 bytes, algorithm SHA-256, and the complete 64-character digest. If the file is copied into a protected raw-data directory, compute or verify the digest there as well. Matching digests show that the copy has the same bytes as the received file, subject to the hash's collision-resistance assumption.
The file size and dates help a person investigate a mismatch, but they do not substitute for the checksum. A different file can have the same size, and a timestamp can be copied or altered. Conversely, if the checksum matches but the recorded source is wrong, the digest does not correct the provenance record.
Connect the Manifest to Each MICE Run
A project-level manifest identifies files that exist in the project; a run-level record identifies which exact inputs a particular analysis used. The distinction matters when a project contains several source versions or when preprocessing creates a new data file. A run record should point to the input artifacts actually read by the analysis, including relevant derived files, and record their checksums. It should also identify the run unambiguously, for example with a run label and date, and refer to the analysis code or project revision used.
If preprocessing converts a raw export into an analysis-ready data set, record that output as a separate artifact with its own path and checksum. The provenance record should make the connection explicit: which raw file was read, which preprocessing step produced the derived file, and which derived file entered the MICE workflow. This records the chain without making the raw file appear to be the direct input when it was not.
Store the original bytes in the raw-data location and avoid editing that copy.
Log the source, names, dates, file size, and a checksum for each source artifact.
Save processed data separately and give each relevant output its own path and checksum.
Recompute checksums for the files the run will read and compare them with the recorded expected values.
Record the run label, date, input paths and checksums, derived inputs, and analysis-code identifier together.
Worked Example: Checking a Derived Input Before Imputation
In a hypothetical project, clinic_export.csv is processed into analysis_input.rds. The run record lists the raw-file checksum and the checksum of the processed file. Before a planned run, the analyst recomputes the processed-file checksum. The recorded value is 41bd…77e0, while the newly computed value is 41bd…77e0. Because the complete values match, the file currently at that path has the same bytes as the file recorded for the run.
Now suppose the next check yields 41bd…77e1. The values differ, so the analyst must not proceed as if the input were verified. The changed final hexadecimal character is enough to indicate a mismatch; it does not reveal what changed or whether the change was intentional. The analyst checks the file's source, size, timestamps, and transformation history, then either restores the recorded artifact or documents a new artifact and creates a new run record. The old record is retained rather than silently rewritten.
A matching checksum supports a precise statement: the verified file has the same bytes as the file represented by the recorded digest. It does not establish that the file was the correct data set, that preprocessing was correct, or that a MICE model was suitable.
Justification: Why a Checksum Detects a Changed Input
A checksum is useful because it maps a potentially large file to a compact digest in a reproducible way. If the input bytes are unchanged and the algorithm is the same, the computed digest is the same. If bytes change, the hash's design makes a digest change overwhelmingly likely. For SHA-256, there are \(2^{256}\) possible digests; this large output space makes accidental collisions negligible for routine file verification, although no finite digest can uniquely encode every possible file.
The second implication is deliberately probabilistic, not absolute. The number of possible files exceeds the number of 256-bit digests, so collisions must exist in principle. For ordinary provenance checks, a well-established cryptographic hash is a practical way to detect accidental changes. For stronger protection against deliberate tampering, restrict write access and preserve the manifest in a protected or independently controlled location; a checksum stored beside a mutable file can be changed along with it.
Diagnostics, Alternatives, and Limits
When verification fails, treat the mismatch as a signal to investigate, not as a minor warning to dismiss. Check whether the run is pointing to the intended path, whether a file was overwritten, whether a transfer or archive process altered it, and whether the recorded checksum was computed with the stated algorithm. Compare the file size and available source records. If an intentional correction or transformation explains the difference, preserve the new artifact and document its relationship to the old one; do not edit the old digest to make the check pass.
Checksums complement, rather than replace, other provenance tools. File names are easy to read but can be reused for different contents. Modification dates are convenient clues but can change during copying and may not be trustworthy. Backups can restore a file but do not by themselves identify which version was analyzed. Version control can help track scripts and small text files, but is not a substitute for a data manifest or an appropriate archive for large or sensitive data. A manifest is especially useful for connecting file identity with origin and run context; a checksum alone cannot supply that context.
A byte-level checksum also has a deliberate limitation: harmless formatting changes produce a different digest. Re-saving a table with a different line ending, encoding, or column order may change the bytes even if the records appear equivalent. Do not respond by ignoring the mismatch or replacing the original checksum with a checksum of a normalized version. Preserve the source checksum, then, if a normalized artifact is needed, save it separately and record its own checksum and transformation. This keeps “same bytes” distinct from “same interpreted data.”
Provenance records can be incomplete or misleading if entered carelessly. A checksum computed only after a source file has already been modified cannot show what the original contained. A correct digest attached to the wrong file name still misidentifies the input. A file may be accurately tracked but contain incorrect or incomplete data. Provenance supports auditability and reproducibility; it cannot certify data quality or resolve statistical assumptions about missingness.
Worked Example: Distinguishing a New Source Version
Suppose a hypothetical provider sends followup.csv twice. The first copy was acquired on 3 March and has digest c210…a18b. A replacement arrives on 6 March with the same file name and the same size, 9,600 bytes, but digest 73fe…09d2. The equal sizes do not establish that the files are identical. The different digests establish that the bytes differ, barring a cryptographic collision.
The correct record keeps both versions, their acquisition dates, and their separate checksums. It notes that the 6 March file is a provider replacement, if that is what the provider states. If a MICE run used the first copy, its run record continues to refer to the first digest. A later run using the replacement gets a new run record referring to the second digest. This makes it possible to distinguish a change in results due to changed data from other changes to the analysis.
The checksums do not explain why the provider changed the file, which rows differ, or which version is substantively preferable. Those questions require source documentation and an appropriate data review.
Common Mistakes
- Editing the raw file and calling it the source. Keep transformations in separate outputs so the received artifact remains available for verification.
- Using a timestamp as proof of identity. Dates can be altered or changed by copying. Record them as context, and use a checksum to compare exact bytes.
- Updating a manifest in place after a mismatch. Preserve the earlier record and document a new artifact or a correction. Otherwise, the record no longer explains what an earlier run used.
- Assuming a matching digest proves the data are correct. It identifies bytes relative to a recorded digest; it does not validate content, origin, preprocessing, or analysis.
- Checking only the original source when the run reads a derived file. Record and verify every relevant file actually used as input, including processed data.
Check Your Understanding
Answer each question, then compare your reasoning with the solutions below.
- A file is copied to a new folder. Its modification date changes, but its SHA-256 digest matches the recorded value. What can and cannot be concluded?
- A processed data file has a different checksum from the one in the run record. What should the analyst do before running MICE?
- Two versions of a source file have identical names and sizes but different checksums. Should the earlier run record be updated to the newer checksum? Explain.
- Name two things a matching checksum does not establish.
Solutions. (1) The copied file has the same bytes as the file represented by the recorded digest, assuming the digest was recorded correctly and the hash has no collision. The changed date does not show that the contents changed; a matching digest does not authenticate the source or validate the data. (2) Pause the run, investigate the path, file history, size, source, and transformation record, then restore the verified artifact or document the new artifact and create a new run record. Do not silently replace the expected checksum. (3) No. Keep the earlier record tied to the file used in that run; preserve both versions and create a separate record for any later run using the newer file. (4) A matching checksum does not establish that the data are accurate, that they came from the claimed source, that preprocessing was correct, or that the imputation model is appropriate.