Fisher-R1: Training LLM Agents for Reliable Hypothesis Testing

Jiacheng Miao, Jin Mu, Guanhua Chen, James ZouNeurIPS 2026

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$).

Figure 1: Open-ended hypothesis testing with coding agents. Left: GPT-5.4 identifies outliers but still applies linear regression, leading to a false discovery. Fisher-R1 instead uses a rank-based test and correctly fails to reject the null. Right: P-Bench accuracy on easy and hard splits.

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:

  1. 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.
  2. 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@1 jumps 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

Abstract

Reliable hypothesis testing is the foundation of many empirical scientific claims. Large language model (LLM) agents are increasingly used to automate this process, as they can inspect datasets, generate code, and produce analyses end-to-end. However, we show that they frequently make subtle inferential errors that lead to incorrect conclusions despite correctly executed analyses. Existing benchmarks fail to capture this failure mode, as they rarely assess whether a reported p-value is statistically valid given the assumptions underlying the data. We address this gap by building P-Bench, a benchmark comprising 425 open-ended, realistic hypothesis-testing tasks spanning economics, biology, and medicine. Each task requires an agent to select a statistical method, compute a p-value, and draw a conclusion given only a scientific hypothesis and a dataset. We further introduce Fisher-R1, an open-weight LLM agent trained for rigorous hypothesis testing using synthetic tasks and reinforcement learning. On P-Bench, Fisher-R1-14B substantially improves over its backbone and outperforms strong proprietary and open-source baselines, including GPT-5.4 and DeepSeek-V4-Pro, achieving a 21% average relative improvement in single-trial success over DeepSeek-V4-Pro, with gains up to 26% on the most challenging tasks. Our results demonstrate that current LLM agents lack reliable statistical reasoning for hypothesis testing and that reinforcement learning on tasks with verified statistical reward substantially improves reliability. Code is available at https://github.com/jmu27/FisherR1.
BibTeX
@inproceedings{miao2026fisher,
  author = {Jiacheng Miao and Jin Mu and Guanhua Chen and James Zou},
  title = {{Fisher-R1: Training LLM Agents for Reliable Hypothesis Testing}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=ShMNgympCf},
}
Figure