AI Agents and Prompt Engineering in Econometric Coding
We study how large language models write code for econometric analysis. We compare three dimensions of AI-assisted coding: statistical software (Stata, R, or Python), prompting (zero-shot versus few-shot), and the degree of agency, from a chatbot that writes a single script to an agent that executes and revises its own code. On a benchmark of applied econometric and statistical tasks, moving from the chatbot to the constrained agent raises task success from 74 to 96 percent, at about eight additional cents per run. For Claude Sonnet 4.6 and GPT-5.4 through Codex, few-shot prompting improves the chatbot far more than the constrained agent, indicating that prompting and agency act as substitutes. For these models, differences across statistical software are sizeable under the chatbot but largely disappear under the constrained agent.
-
-
Copy CitationSebastian Galiani, Federico Ariel López, and Raul A. Sosa, "AI Agents and Prompt Engineering in Econometric Coding," NBER Working Paper 35588 (2026), https://doi.org/10.3386/w35588.Download Citation