Chiosa
Machine Learning

A replay method corrects p-values after agents choose analyses

Inference after coding agents · arXiv:2611.23174

3 min
Updated

In plain words

A p-value is a number researchers use to judge how surprising a result would be if there were no real effect. It can be misleading when a coding agent looks at data, chooses an analysis that seems promising, and reports a p-value from those same data.

Selective replay reruns the agent on smaller samples and checks how often it chooses the same analysis when that analysis looks favorable.

In simulated studies with no real program effect, the original agent often reported small p-values, while the replay correction brought the rate of rejections close to the expected level in that setting.

The research

A result can look more convincing than it should when an agent chooses what to test after seeing the data. Knowing whether its reported p-value accounts for that choice changes how much confidence readers can place in the number and whether it should be adjusted.

Selective replay estimates how a coding agent’s data-driven analysis choice affected its p-value, then adjusts that value for selection.

The method runs the original analysis code on subsamples, then replays the agent on samples where that analysis looks more or less favorable. Comparing how often the agent chooses the same analysis in each group estimates the selection effect and adjusts its original p-value.

In simulated studies with zero program effects, the adjusted test’s rejection rate was close to the expected level, while the agent’s original p-values often fell below it. This supports the correction in that setting; theory gives a conditional, asymptotic guarantee under additional assumptions.

The validity guarantee is asymptotic and depends on accurate analysis code, agent reports and matching, along with assumptions about how analyses recur and behave across sample sizes. The method also assumes the prompt is fixed independently of the data and sampling units are independent.

What the evidence shows

  • Selection changes the question

    Selective replay is a statistical method for correcting p-values when a coding agent chooses an analysis after inspecting data. A p-value that is valid for an analysis chosen in advance need not remain valid after the agent selects that analysis using the same data.

    The risk does not depend on the agent deliberately hunting for a favorable result; trying alternatives and then choosing one can also make the analysis data-dependent.

  • Replay measures selection

    The method estimates how often the agent reselects its original analysis on subsamples where that analysis looks favorable, compared with subsamples where it looks less favorable. The key comparison is between those replay frequencies.

    It provides an estimate of the selection effect that can be used to adjust the original p-value, rather than treating the original result as if the analysis had been fixed in advance.

  • A null simulation tests correction

    Across simulated datasets where program effects were zero, original agent p-values often suggested rejection, while the replay test’s rejection rate was close to the expected level. This comparison shows that replay correction brought rejection frequency near its target in this simulated setting.

  • Theory bounds the claim

    The method’s theory explains why this correction can work: under stated assumptions, its p-value is asymptotically valid conditional on the agent having selected the analysis. A stronger stability assumption gives an exact uniform distribution in the limit.

    That conclusion depends on the assumptions, including accurate implementation and matching, adequate replay counts and stable selection behavior across sample sizes.

  • Correction can preserve significance

    In one survey-data application, selective replay raised the p-value for the selected regression, but the corrected result remained statistically significant, including under the reported one-sided confidence band.

    This example shows that accounting for selection can weaken a result without necessarily removing its significance.

Deep

Next paperA fused TPU kernel cuts expert-work delays in MoE inference