TL;DR
Large language model (LLM) coding agents can write flawless R scripts that run without a single syntax error—and still walk you straight into a false scientific discovery because they chose the wrong statistical test for the data. This paper introduces P-Bench, a benchmark that catches these subtle statistical traps on real scientific datasets, alongside Fisher-R1, an open-weight agent trained with reinforcement learning that beats massive frontier models at rigorous hypothesis testing.
What Problem Does This Paper Address?
If you hand a modern LLM agent a CSV file and a research question, it can inspect the columns, write analysis code, and draft a crisp report. The trouble is that code execution is not statistical reasoning.
Imagine testing whether mutation burden correlates with tumor purity in a cancer dataset. Two extreme outliers sit in the corner of the plot. Even when a frontier model like GPT-5.4 notices those outliers, it often defaults to standard linear regression anyway, gets a tiny $p$-value ($p < 2.2\times 10^{-16}$), and confidently proclaims a discovery. A human statistician—or a properly trained agent—switches to a rank-based Spearman test, compresses the outliers, and sees there is actually no significant effect ($p = 0.085$).
Existing benchmarks miss this failure mode. They either check factoids ("what is the mean of column X?"), score predictive accuracy, or ask multiple-choice questions without running code. None test the full, open-ended loop: inspecting messy data, checking statistical assumptions, executing code, and producing a valid $p$-value.
Methods
To teach an LLM to think like a cautious statistician, the authors built Fisher-R1 (based on Qwen2.5-Coder 7B and 14B backbones) that interacts with an executable R sandbox in a multi-turn ReAct-style loop (<think>, <code>, <observation>, <answer>). Training happens in two stages:
- Supervised Fine-Tuning (SFT) Warm-Start: They prompt Claude-Sonnet-4.6 to solve synthetic tasks following a strict five-step statistical workflow (basic exploratory data analysis, detailed checks, assumption testing like normality or parallel trends, method selection, and conclusion), keeping ~3,850 verified trajectories.
- Outcome-Grounded Reinforcement Learning (RL): Using the DAPO algorithm, the agent practices in the R sandbox and receives a rule-based reward gated on valid code execution.
What’s clever here is the reward function. First, they don't explicitly reward picking a specific named test, since multiple tests can be statistically defensible; instead, bad methods naturally yield off-target $p$-values. Second, raw $p$-values are squished near zero—the gap between $0.5$ and $0.6$ means nothing, while $0.1$ vs. $10^{-10}$ is monumental. So the authors convert $p$-values into two-sided standard-normal $z$-scores ($z(p) = \Phi^{-1}(1 - p/2)$) and reward closeness in $z$-space (90% weight), plus a small bonus (10% weight) for getting the reject/fail-to-reject decision right at $\alpha = 0.05$.
Datasets
- P-Bench (Evaluation): A newly introduced, expert-audited benchmark of 425 real-world tasks drawn from Harvard Dataverse (economics), cBioPortal (cancer biology), and Vanderbilt Biostatistics course notes. Split into P-Easy (203) and P-Hard (222), it spans 17 method families (from $t$-tests to Cox regression and IV/2SLS) and includes adversarial real-world traps like heteroskedasticity, clustering, and outliers. Every answer key comes from a logged, reproducible run of the original canonical R code.
- Synthetic Training Corpus: Because verified real-world tasks are scarce, Fisher-R1 trains exclusively on 8,642 synthetic tasks generated across a 6-factor grid (method, domain scenario, sample size, auto-calibrated effect size, prompt style, and seed) plus injected data-quality issues like missing or extreme values. Crucially, P-Bench stays completely out-of-distribution.
Key Insights and Ideas
- Binary conclusions hide sloppy science: Models routinely guess the right binary direction ("reject the null") nearly twice as often as they compute a $p$-value that is actually close to the canonical analysis. Measuring binary decisions alone dramatically overstates how reliable LLM scientists really are.
- Targeted statistical rewards beat brute-force model scale: A 7B or 14B coding model trained with verified $z$-space rewards outperforms general-purpose giants (like GPT-5.4 and DeepSeek-V4-Pro) as well as RAG setups that retrieve R documentation.
- SFT and RL are synergistic: SFT alone teaches the agent how to explore data (broadening
pass@3), while RL sharpens single-try reliability (pass@1). You need both to peak.
Key Results
Models are scored on Raw accuracy (correct reject/fail-to-reject at $\alpha = 0.05$) and Strict accuracy (correct decision and $|\Delta z| < 0.5$).
- Massive gains over backbones: On Qwen2.5-Coder-7B, Strict
pass@1jumps from 36.3% to 65.7% on P-Easy and 13.2% to 30.6% on P-Hard, slashing operational failures from 43.5% down to 8.5%. - Beating frontier baselines: Fisher-R1-14B achieves 33.0% Strict
pass@1(45.5%pass@3) on P-Hard, outperforming GPT-5.4 (30.5%pass@1, 39.2%pass@3) and DeepSeek-V4-Pro (26.3%pass@1, 42.5%pass@3), marking up to a 26% relative improvement over DeepSeek-V4-Pro on the hardest split. - True generalization: Semantic embedding comparisons confirm that P-Bench prompts sit well outside the synthetic training distribution—the agent learned statistical habits, not memorized templates.
Limitations and Future Work
The framework currently lives strictly in the frequentist, single-hypothesis world at a fixed $\alpha = 0.05$ threshold. It does not evaluate multiple-comparison corrections, Bayesian evidence, choosing $\alpha$ itself, or whether an effect size actually matters practically in the real world. The authors emphasize that Fisher-R1 is an oversight tool—not a replacement for human statisticians—and point toward teaching future agents to explicitly justify assumptions, quantify uncertainty across competing models, and recognize when no single hypothesis test can answer a scientific question.
Summary updated