Can AI write your code? A case study of chatgpt’s statistical coding capabilities for quantitative research

Debra Winberg et al.

Health Economics Review2026https://doi.org/10.1186/s13561-025-00714-8article
ABDC C
Weight
0.50

What the paper says

Abstract Background Recent advancements in Artificial Intelligence (AI), particularly in large language models (LLMs) like OpenAI’s ChatGPT, have extended its applications well beyond simple dialogue generation. ChatGPT has shown potential in supporting data-driven decision-making. ChatGPT has gained traction in academia for its ability to generate code for data analysis, providing robust support for programming languages. This study aims to evaluate ChatGPT’s ability to generate code for causal inference and data analysis. Methods This study evaluates ChatGPT4.0 Pro’s performance in coding Difference-in-Differences (Diff-in-Diff ), Inverse Probability Treatment Weighting (IPTW), and Regression Discontinuity (RD) using problem sets and reference code from “Causal Inference: The Mixtape”. The evaluation was conducted in Python, Stata, and R. Researchers provided structured prompts and feedback, and a fourth researcher replicated all tasks to assess consistency. Primary outcomes included accuracy, efficiency, error output, editing needs, and inter-user consistency. Results ChatGPT generated accurate code and results in R and Python for most tasks. However, it struggled with IPTW and performed less reliably in Stata. Errors were often related to data management or figure generation. Although ChatGPT could replicate correct results, the structure and syntax of its code varied across users and sessions. Conclusions ChatGPT shows strong potential as a supportive tool for econometric coding tasks in health economics, especially in Python and R. However, its output still requires human interpretation and validation. As generative AI continues to evolve, these tools hold promise for streamlining research tasks but remain supplementary to skilled human researchers in quantitative research.

Open paper page →

Cite this paper

https://doi.org/https://doi.org/10.1186/s13561-025-00714-8

Or copy a formatted citation

@article{debra2026,
  title        = {{Can AI write your code? A case study of chatgpt’s statistical coding capabilities for quantitative research}},
  author       = {Debra Winberg et al.},
  journal      = {Health Economics Review},
  year         = {2026},
  doi          = {https://doi.org/https://doi.org/10.1186/s13561-025-00714-8},
}

Paste directly into BibTeX, Zotero, or your reference manager.

Flag this paper

Can AI write your code? A case study of chatgpt’s statistical coding capabilities for quantitative research

Flags are reviewed by the Arbiter methodology team within 5 business days.


Evidence weight

0.50

Balanced mode · F 0.40 / M 0.15 / V 0.05 / R 0.40

F · citation impact0.50 × 0.4 = 0.20
M · momentum0.50 × 0.15 = 0.07
V · venue signal0.50 × 0.05 = 0.03
R · text relevance †0.50 × 0.4 = 0.20

† Text relevance is estimated at 0.50 on the detail page — for your query’s actual relevance score, open this paper from a search result.