Code Translation using Large Language Models: What’s the role of the Research Software Engineer?

The Stata2R Logo, an R overlaid with white squares.

Stephen Thompson, Asif Tamuri

UCL Centre for Advanced Research Computing and UCL Innovative Clinical Trials Unit

2026-09-09

Today’s Talk

  • Brief Introduction (UCL ICTU, UCL ARC)
  • Code Translation Motivation
  • Code Translation Mechanics
  • Workshop Results

Innovative Clinical Trials Unit and ARC

A screenshot of the Innovative Clinical Trials Unit website A plus sign A screenshot of the Advanced Research Computing website, stating that ARC is UCL's research, innovation and service centre for the tools, practices and systems that enable computational science and digital scholarship.

  • Experts in clinical trial design and analysis - statisticians.
    • Impact through successful clinical trials / publications.
    • A lot of software written in Stata.
  • Research software engineers
    • Collaboration to create impact through software.

About Stata

  • Closed source commercial statistics software.
  • Supports community contribution with a package library and publication through the Stata journal.
  • Stata journal encourages good software practice - tests, documentation.

Motivation: Example artbin.

A screenshot of the artbin publication in the Stata Journal titled artbin: Extended sample size for randomized trials with binary outcomes.

Motivation: Example artbin.

  • High quality software (including documentation and tests)
  • Demonstrated impact - used and cited in published trials.
  • Open source (GPL3) - free to download/modify
    • need Stata License to run.
  • Stata community is tiny compared to R or Python.
  • Can we increase impact by translation.

Stata2R: Practicalities

  • Pre-requisites:
    • Well written/documented/tested Stata code 👍
    • Language Expertise (Stata and R)
    • Domain Expertise (Statistics)
    • Time (funding)
  • Lets leverage advances in agent based code translation?

Agentic Coding (Claude Code)

  • Users communicate in plain text (for example “translate artbin to R”)
    • Non deterministic (stochastic sampling from many possible answers).
    • Will usually do what you ask, which may not be a good thing.
  • We developed the Stata2R plugin with 4 skills to limit the impact of non deterministic behaviour and unquestioning behaviour.
  • We delivered a 4 hour workshop to use the plugin.

What’s in a Plugin / Skill

Skills are defined in markdown.

  • Plugins are collections of skills that are easy to install

    /plugins marketplace add https://github.com/stata-translations/Stata2R.git
    /plugin install stata-translation
    /reload-plugins
    /stata-translation:hello
  • /stata-translation:translation-strategy
    
  • /stata-translation:stata-to-pseudocode
    
  • /stata-translation:pseudocode-to-r
    
  • /stata-translation:add-missing-tests
    

Plugin Skill 1: Translation Strategy

  • Summarise the purpose of the library.
  • Is it worth translating? (existing R libraries, users etc)
  • Is the documentation and testing sufficient to enable a good translation.

Plugin Skill 2: Stata to Pseudocode

  • Evidence that two stage translation creates better code.
  • Enables a human review step.
  • Use any documentation files (.sthlp) to inform the translation.
  • Ignore all files in the testing directory.

Plugin Skill 3: Pseudocode to R

  • Use the pseudocode to create an R package.
  • Create automated tests.
  • Port Stata documentation and examples to R (create vignettes)
  • Port any dialogues (graphical user interfaces) to R.
  • Copy over licence file and create README, CONTRIBUTING, files etc.

Plugin Skill 4: Add Missing Stata Tests to R

  • Port the Stata tests to R and confirm they pass.
  • Document Stata to R test correspondence and verify results.

Developed a training program.

We developed and delivered a Workshop to
10 statisticians aiming to:

Pre-Workshop: Stata and R Fluency

Post-Workshop: Skills assessment (Target language quality).

Post-Workshop: Skills assessment Example (Time Taken).

Post-Workshop: Concerns Work Cloud

Post-Workshop: Ideas for Improvements / Future Work.

Further Considerations

  • Ongoing development (do you plan on maintaining both versions?)
  • Are you complying with the original license?
  • Who owns the copyright?
  • Preventing access to sensitive data.

Summary

  • Claude can translate code.
  • Results are non deterministic.
  • The plugin provides some structure, but human intervention is still required to keep Claude on track.

With Thanks to:

James Carpenter, Tra My Pham, Asif Tamuri, David Fisher, Matteo Quartagno, Carlos Diaz Montana, Ian White, Toby Thompson

Links:

Slides: https://doi.org/10.5281/zenodo.22124100

Workshop Results: https://doi.org/10.5281/zenodo.22093626

Stata2R Plugin: https://github.com/stata-translations/Stata2R

Link to https://stata-translations.github.io/talks-stata-conference/