Tutorials › Causal Inference › Auditing Longitudinal Tables For Temporal Misclassification

Time-Varying Treatments and Confounding · Tutorial 699 of 972

Auditing Longitudinal Tables For Temporal Misclassification

Use event-level timing and explicit audit flags to identify when a longitudinal table may assign a covariate to the wrong side of treatment.

Intermediate 11 min read

What You'll Learn

  • Distinguish visit labels from evidence about when events occurred
  • Audit date precision, time zones, source fields, and event definitions
  • Identify same-visit treatment and covariate records whose order is unknown
  • Detect how date truncation and sorting can hide or create apparent sequence
  • Record unresolved timing uncertainty without silently assigning an order

Why Temporal Audits Matter

In longitudinal causal analysis, the order of events can determine whether a measured covariate is treated as information available before a treatment decision or as information recorded after that decision. A table may contain separate columns for treatment and covariates at each visit, yet that layout alone does not establish their temporal order. A visit number is an organizational label, not necessarily a timestamp.

An audit asks whether the data support the temporal sequence implied by their indexing and coding. It does not, by itself, establish that a covariate confounds a treatment effect or determine which causal method should be used. Its purpose is narrower and essential: to find records for which the observed or coded order may not match the event order, to document why, and to distinguish resolved cases from genuinely uncertain ones.

Definition: Temporal misclassification occurs when a record, coding rule, or analysis assigns an event to a time or sequence that differs from the event’s actual timing, or when the available data do not justify the assigned order. An ambiguous temporal record is one for which the available information cannot establish the relevant order, such as whether a covariate measurement preceded a treatment administration.

Let \(A_t\) denote treatment at indexed time \(t\), and let \(L_t\) denote a measured covariate at that time. These subscripts are useful only when their meaning is clear. For example, a data system might define \(L_t\) as measured before the treatment decision \(A_t\); another might collect both during a visit without recording which came first. The table’s variable names do not settle the convention. A causal diagram with repeated variables is meaningful only insofar as the time indices correspond to a defensible event order.

What to Inspect in a Longitudinal Table

Begin by separating the different time concepts that are often compressed into a single “date” or “visit” field. A scheduled visit date, the date a measurement was taken, the date a treatment was prescribed, and the date the treatment was administered can all differ. The relevant event depends on the scientific definition of treatment and covariate. For a treatment defined as receiving a dose, for instance, an order date is not automatically the administration time.

For each treatment and covariate record, inspect the original time fields and their provenance. Ask whether the value records the event time, entry time, order time, or time of later data extraction. Check whether times include a clock time and time zone; whether dates were rounded, shifted, or converted; and whether a missing time means “not recorded” rather than “occurred at the visit.” Also check for duplicate records, delayed entry, corrections, and whether a visit number was assigned from scheduling rather than actual attendance.

A useful audit preserves the raw fields and adds explicit derived fields rather than overwriting the source. For a treatment and covariate pair, an audit record can include the subject identifier, event descriptions, original timestamps, source systems, date precision, the calculated order when possible, and a status such as “covariate before treatment,” “treatment before covariate,” “same recorded time,” or “order unresolved.” “Same recorded time” and “order unresolved” are not interchangeable with evidence that events were simultaneous.

Worked Example: A Visit Date Hides a Dose Before a Measurement

Suppose a hypothetical table for participant P041 has one row for May 6. It lists a severity score and treatment at that visit, with the visit date as the only time field. The source records show that the dose was administered at 08:00 and the severity measurement was taken at 08:10. The treatment is defined as dose administration, not prescription.

Step 1: Compare the event times. Let the signed time difference be measurement time minus administration time:

$$ 08{:}10 - 08{:}00 = 10 \text{ minutes}. $$

The measurement occurred 10 minutes after the dose. Thus, the source records establish that this particular severity measurement is not a pre-dose measurement. The visit-date-only table hides that order because both events are stored under May 6.

Step 2: Check whether the time fields refer to the right events. If the 08:00 field were actually an order-entry time rather than administration time, the comparison would not establish when treatment was received. Here, the hypothetical source documentation explicitly identifies it as administration, so it is the relevant event time under the stated treatment definition.

Audit conclusion. Flag the table’s same-day row as temporally misleading if its structure implies that the severity score was measured before treatment. Preserve the source timestamps and record the established order. Do not infer that a different, unrecorded severity measurement occurred before the dose.

Same-Visit Records Need an Ordering Rule

When treatment and a covariate are recorded at the same visit, there are several possibilities. The covariate may have been measured first and informed the treatment decision; treatment may have occurred first and the covariate was measured afterward; or the records may be too coarse to distinguish these cases. A shared visit label, calendar date, or rounded timestamp does not choose among them.

If an analysis convention defines \(L_t\) as information measured before \(A_t\), then assigning a same-visit measurement to \(L_t\) requires evidence that it was available before treatment. If it is known to have occurred after treatment, it should not be presented as a pre-treatment measurement. If order cannot be established, the audit should report that uncertainty rather than force the record into either category. This is a data-quality conclusion, not a claim that all same-visit pairs are unusable.

Worked Example: Resolving a Same-Visit Pair With Source Times

In a hypothetical clinic table, participant P116 has a visit-2 severity score and a visit-2 dose. Both are initially recorded only as occurring on June 12. The clinical measurement system later supplies a measurement time of 09:05, and the administration record supplies a dose time of 09:20. Assume both fields refer to the events named and use the same local time zone.

Step 1: Calculate the ordering difference. Define the time difference as dose time minus measurement time:

$$ 09{:}20 - 09{:}05 = 15 \text{ minutes}. $$

The severity measurement preceded dose administration by 15 minutes. Under a convention in which \(L_t\) represents a covariate measured before \(A_t\), this record supports assigning the measurement to the pre-treatment side of the visit-2 dose.

Step 2: Check the scope of that conclusion. The conclusion applies to this participant and this pair of events. It does not establish a universal clinic workflow or prove that every visit-2 severity score was measured before its dose. For other records, the timestamps and sources must be checked independently.

Step 3: Retain the audit trail. Keep the original date-only entries, the more precise source timestamps, the time-zone assumption, and the resulting order flag. If the timestamp source or time-zone interpretation were unknown, the 15-minute comparison would not be sufficiently justified and the order would remain unresolved.

How Coding Can Conceal or Distort Sequence

Temporal order can be lost even when event times were originally available. Common causes include truncating dates to month or year, replacing timestamps with visit numbers, rounding times to the nearest hour, converting time zones incorrectly, and sorting by a variable or row number that is unrelated to event timing. A table sorted with treatment rows first may look as though treatment preceded covariates, but row order is not event-time evidence.

A simple mathematical reason explains why date truncation is risky. Let \(f(t)\) be a coding rule that maps an exact event time \(t\) to a coarser label, such as its calendar month. If two distinct times \(t_1\) and \(t_2\) fall in the same month, then \(t_1 < t_2\) can hold while \(f(t_1)=f(t_2)\). The coded values no longer reveal which event came first. Coarsening can therefore erase a supported order; it cannot justify an order that the coarsened values do not contain.

Justification: Suppose a coding rule maps every event in August to “August.” For an event on August 4 and another on August 27, both receive the same coded value. The original times satisfy August 4 < August 27, but their coded labels are equal. Because equality of the labels is compatible with either event having occurred first, the coded table alone cannot recover the ordering.

Worked Example: Monthly Coding Erases Opposite Orders

Consider two hypothetical participants. For P203, a covariate measurement occurred on August 4 at 08:00 and treatment was administered on August 27 at 08:00. For P204, treatment was administered on August 4 at 08:00 and the covariate was measured on August 27 at 08:00. Suppose the analysis table retains only the month and year for each event.

Step 1: Establish the exact intervals. In each case, the events are 23 days apart: August 27 minus August 4 is 23 calendar days. For P203 the covariate came first; for P204 treatment came first.

Step 2: Apply the coding rule. Both events for each participant become “August,” so P203 has covariate month = treatment month, and P204 also has covariate month = treatment month. The monthly fields fail to distinguish the two opposite sequences.

Step 3: State the audit finding. The month-coded table cannot establish whether the covariate preceded treatment for either participant. If the exact timestamps remain in a source system, they can be used to restore the ordering and the derived order should be documented. If they are unavailable, both pairs must remain unresolved; assigning order from column position or an assumed visit convention would add information not present in the table.

A Practical Audit Sequence

A reproducible audit separates source review from decisions about how to represent time in the analysis. The following sequence helps keep those tasks explicit.

1
Define the events.
Write down what counts as treatment and what counts as covariate measurement. Distinguish, for example, a treatment order from administration.
2
Trace time fields to their sources.
Record whether each field represents event time, entry time, scheduled visit, or another time concept. Note date precision and time zone.
3
Compare paired events.
For each relevant treatment-covariate pair, classify the order only when the source information supports it. Keep tied and unresolved cases distinct.
4
Inspect transformations and table layout.
Check whether truncation, rounding, visit numbering, sorting, or reshaping has removed or implied an order not supported by the source.
5
Document decisions and remaining uncertainty.
Preserve raw fields, derived fields, rules, and unresolved counts so a later analysis can be interpreted in light of the actual timing evidence.

An audit summary can report counts by status, along with the denominator and the unit being counted. For example, “12 of 80 treatment-covariate pairs had unresolved order” describes the reviewed pairs; it is not automatically a population rate or a measure of causal bias. If several pairs belong to one participant, report that the count is of pairs rather than participants.

Common Mistakes and Why the Audit Matters

  • Treating the visit number as a timestamp. Visit 2 follows visit 1 as a label, but a rescheduled visit or late-entered record can break a simple assumption about event times. Check the event dates.
  • Calling a shared date “simultaneous.” A date without clock times only shows that both events were recorded on that date. It does not show that they happened at the same moment.
  • Using data-entry order as clinical order. The order in which records were entered, exported, or sorted may have no relation to when events occurred.
  • Silently resolving uncertain pairs. Assigning every same-visit covariate to the pre-treatment side may create a temporal claim unsupported by the records. Mark uncertainty and state the rule used for any analytic representation.
  • Confusing an audit flag with a causal conclusion. Finding that a covariate was measured after treatment does not, by itself, establish its causal role or determine the appropriate effect estimator.

The practical consequence is that temporal errors can change the histories represented by a longitudinal table. A covariate placed before treatment is presented as potentially available before the treatment decision; one placed after treatment is not. If the recorded sequence is wrong, downstream descriptions of time-varying confounding and treatment-covariate feedback may be based on a history the data do not support. Careful auditing does not remove all uncertainty, but it makes the evidence and limits visible.

Key takeaway: A longitudinal table’s rows, visit labels, and column order do not prove event order. Base temporal classifications on event-specific source information, preserve the original timing fields, and leave genuinely ambiguous pairs explicitly unresolved.

Check Your Understanding

Use the audit principles above to answer these questions.

  1. A treatment order is dated October 3, while the first documented administration is October 5. Which date is relevant if treatment is defined as receiving the medication, and what additional information should you verify?
  2. A covariate and treatment share a date, but neither has a clock time. What can and cannot be concluded about their order?
  3. Why can sorting same-visit records with treatment first not establish that treatment occurred first?
  4. Two events have exact dates 12 days apart but both are coded as occurring in the same month. What temporal information has been lost?
  5. An audit finds 9 unresolved pairs among 60 reviewed pairs. State the unresolved-pair proportion and explain why it is not automatically a population estimate.
Clinical Biostats