stat.MENov 17, 2026

Inference after coding agents

Authors: Florian Gunsilius, David Van Dijcke, Kaspar Wüthrich

Organizations: Department of Economics, Emory University · Department of Economics, University of Virginia · Department of Economics, University of Michigan · CESifo

Abstract

Empirical research is changing rapidly as AI coding agents are becoming increasingly proficient in every step of it, from writing code to manipulating data. We argue that while the potential of coding agents for science is vast, their use in hypothesis testing poses a substantial threat to classical inference, as these agents enable a supercharged form of selective inference. In particular, we argue that coding agents carrying out empirical research introduce a new type of post-selection inference that combines human-like, open-ended search over an implicit space of estimators with programmatic replayability of both the selection and the estimation process. Indeed, we find that on simulated data with zero effects, four frontier agents report significant p-values between 54% and 98% of the time when asked to produce a compelling finding. We propose a simple procedure for detecting and correcting these distortions. After an agent has completed its analysis, we reset and replay it on subsamples of the data to estimate the agent's relative probability of selecting that analysis when it looks statistically favorable. For agents with stable selection behavior, the resulting corrected test is asymptotically valid and consistent conditional on selection. Importantly, the correction is learned from the black-box agent's actual choices rather than a model of how it searches, so it remains valid even as AI technology continues to evolve rapidly. In simulations, the correction robustly lowers the high false rejection rates to near the nominal 5%. We illustrate the method on applications from two published papers.

Figures & tables

Appendix figures & tables11 assets

Supplementary material from the paper’s appendix.

Appendix

Explore similar work

CardsList
  1. Position: Correct Answer, Wrong Mechanism -- When AI Scientists Defend General Claims Their Own Data Contradicts

    Jun 22, 2026Steven Young EuligAI Agent ReliabilityReasoning Evaluation

  2. AI Coding Agents Can Reproduce Social Science Findings

    Jun 9, 2026Meysam Alizadeh, Mohsen Mosleh, Fabrizio Gilardi +2AI Coding AgentsAI Agent Benchmarks

  3. Nonstandard Errors in AI Agents

    Mar 17, 2026Ruijiang Gao, Steven Chong XiaoAI Agent ReliabilityAutonomous Research Agents