Skip to content

DAAF-Contribution-Community/daaf / .claude/skills/stata-r-translation

stata-r-translation

Verified

Stata-to-R translation for data analysis. Maps Stata commands (reghdfe, xtreg, ivregress, margins, esttab, svy:) to R equivalents (fixest, plm, survey, marginaleffects, modelsummary). Use when user has Stata background or requests Stata-equivalent code comments in R pipelines.

references/external-resources.md

View on GitHub
# External Resources for Stata-to-R Translation

Curated catalog of resources for Stata users transitioning to R in quantitative
social science contexts. Each entry includes provenance and quality assessment.

---

## Package-Specific Documentation

### fixest Documentation
- **URL:** https://lrberge.github.io/fixest/
- **Author:** Laurent Bergé
- **Quality:** Excellent
- **Key content:** R implementation of high-dimensional FE estimation. Formula syntax:
  `Y ~ X1 + X2 | fe1 + fe2`. Includes `sunab()` for Sun-Abraham DiD, `etable()` for
  publication tables, `iplot()`/`coefplot()` for visualization. Explicitly references
  both Stata reghdfe and pyfixest for cross-language users.
- **Relevance:** High -- primary regression package in DAAF R stack.

### marginaleffects Documentation
- **URL:** https://marginaleffects.com/
- **Author:** Vincent Arel-Bundock
- **Quality:** Excellent
- **Key content:** Direct R equivalent of Stata's `margins`. Core functions:
  `predictions()`, `comparisons()`, `slopes()`, `hypotheses()`. Every documentation
  page has R/Python toggle. Published in JSS (v111, i09).
- **Relevance:** High -- the original package (Python version is a port).

### survey Package Documentation
- **URL:** https://r-survey.r-forge.r-project.org/survey/
- **Author:** Thomas Lumley (creator/maintainer; CRAN lists co-authors)
- **Quality:** Excellent
- **Key content:** The gold standard for design-based inference. `svydesign()`,
  `svymean()`, `svyglm()`, replicate weights. More comprehensive than both Stata's
  `svy:` and Python's `svy` package.
- **Relevance:** High -- most mature survey analysis implementation across languages.

### rdrobust (R) Documentation
- **URL:** https://github.com/rdpackages/rdrobust
- **Authors:** Calonico, Cattaneo, Farrell, Titiunik (CRAN; rdpackages project)
- **Quality:** Excellent
- **Key content:** Identical API across Stata, R, Python. Local polynomial RD.
- **Relevance:** Very High -- mechanical translation from Stata.

---

## Textbooks with Dual-Language Code

### The Effect: An Introduction to Research Design and Causality
- **Author:** Nick Huntington-Klein
- **URL:** https://theeffectbook.net/
- **Quality:** Excellent. All methods chapters include R, Stata, and Python code.
- **Relevance:** High -- trilingual code examples are the gold standard.

### Causal Inference: The Mixtape
- **Author:** Scott Cunningham
- **URL:** https://mixtape-1ed.netlify.app/ (1st ed.; the 2nd ed., *The Remix*, is in progress at mixtape.scunning.com)
- **Quality:** Excellent. Print edition code in R and Stata; the online 1st edition adds Python code tabs.
- **Relevance:** High -- canonical causal inference textbook.

### Data Analysis for Business, Economics, and Policy
- **Authors:** Gabor Bekes and Gabor Kezdi
- **URL:** https://gabors-data-analysis.com/
- **Quality:** Excellent. All code freely available in R, Stata, and Python.
- **Relevance:** High -- 47 case studies with parallel implementations.

### Using R for Introductory Econometrics
- **Author:** Florian Heiss
- **URL:** https://www.urfie.net/
- **Quality:** Good. Companion to Wooldridge's Stata-based textbook.
- **Relevance:** High -- bridges every Wooldridge example to R.

---

## General Stata-to-R Guides

### Coding for Economists: Coming from Stata
- **Author:** Arthur Turrell
- **URL:** https://aeturrell.github.io/coding-for-economists/coming-from-stata.html
- **Quality:** Excellent. Actively maintained. Python only (Stata→pandas/pyfixest), useful for concepts; for Stata→R see https://stata2r.github.io/ (regression page: https://stata2r.github.io/fixest.html).

### LOST: Library of Statistical Techniques
- **URL:** https://lost-stats.github.io/
- **Quality:** Good. Multi-language Rosetta Stone for statistical methods.
- **Relevance:** High -- look up any technique in Stata, see R equivalent.

### Oscar Torres-Reyna: Panel Data in R
- **URL:** https://www.princeton.edu/~otorres/Panel101R.pdf
- **Quality:** Good. Classic tutorial bridging Stata xtreg to R plm.

---

## Stata Official Documentation (for Reference)

- **Stata Documentation:** https://www.stata.com/features/documentation/
- **Stata Graph Gallery:** https://www.stata.com/support/faqs/graphics/gph/stata-graphs/

Understanding Stata's documentation helps predict which commands users consider
standard and need R translations for.

---

> **Sources:** All resources accessed and verified 2026-05-13.
writing-skillsobra/superpowersUse when creating new skills, editing existing skills, or verifying skills work before deploymentStars: 322kUpdated Claude CodeCodexVerifiedInstall
xlsxanthropics/skillsUse this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .xltx, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like "the xlsx in my downloads") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
shipping-and-launchaddyosmani/agent-skillsPrepares production launches. Use when preparing to deploy to production, or when asking what needs to be in place before shipping. Use when you need a pre-launch checklist, when setting up monitoring, when planning a staged rollout, or when you need a rollback strategy.Stars: 119kUpdated Claude CodeCodexVerifiedInstall
childhoodthedotmack/claude-memBabysit a shipped release after merge, publication, or deployment. Verify published packages, production behavior, installed plugins, and late CI or user reports until the observation window is clean; use babysit for PR readiness before release.Stars: 118kUpdated Claude CodeCodexVerifiedInstall