Stata, R, Mplus, and Python for Social Science Research: Choosing the Software
Students often ask me which statistical program they should learn, usually framed as Stata versus R, and lately as whether Python makes the others unnecessary. My own answer is that I use all four, and the method decides which one I open. That follows from how these programs grew: the most advanced implementation of a given method tends to appear first in a different program depending on who developed the method. If you are new to quantitative methods, the beginner’s guide to quantitative methods in social work research on this site covers what to learn before choosing a program.
Tools by discipline
In a syntax-based program, much of what you can actually run comes from packages written by its users. This is less true of Stata, where StataCorp writes and maintains most of the core estimators, and much more true of R and Python, where nearly every method arrives as a package contributed by a researcher. So the packages available in a program depend on which line of researchers uses it, and a useful way to choose is to ask who those researchers are. Some methods exist in several programs, and some are available in only one.
Stata seems to be the program of economists, especially in econometrics and quasi-experimental designs. In the replication files of American Economic Association journals from 2005 to 2019, about two thirds of the code files were Stata and about 3 percent were R, according to one analysis of that archive. Many of the recent difference-in-differences estimators were released as Stata commands by the econometricians who proposed them, such as csdid by Fernando Rios-Avila with Pedro Sant’Anna and Brantly Callaway, and did_multiplegt_dyn by ClĂ©ment de Chaisemartin, Xavier D’HaultfĹ“uille, and their colleagues.
R is used by data scientists and by quantitative psychologists and psychometricians. The CRAN Psychometrics task view, maintained by Patrick Mair, Yves Rosseel (the author of lavaan), and Kathrin Gruber, links more than 240 packages for item response theory, factor analysis, structural equation modeling, and related models. R is also strong in econometrics; the Econometrics task view lists most of the same difference-in-differences estimators that Stata users install.
Mplus is built by Muthén & Muthén for latent variable modeling, and its users are mostly psychometricians and other researchers who specialize in structural equation modeling. Mixture models, Bayesian SEM, and dynamic structural equation modeling are all in the feature list. Methods for relating latent classes to predictors and distal outcomes without biasing the classes, the three-step approaches described by Asparouhov and Muthén, are built into Mplus as options.
Python is mostly the language of programmers. Machine learning, deep learning, and language models are done in Python or R, and the main libraries for them, such as scikit-learn and Hugging Face’s transformers, are Python libraries.
| Program | Main users | Strengths | Examples |
|---|---|---|---|
![]() | Economists and econometricians | Quasi-experimental designs, survey data, decomposition | csdid, did_multiplegt_dyn, oaxaca, fairlie, firthlogit, svy, margins |
![]() | Data scientists and psychometricians | Psychometrics, networks, meta-analysis, spatial data | lavaan, semTools, mirt, ergm, qgraph, bootnet, metafor, brms, sf |
![]() | Psychometricians and SEM methodologists | Latent variable and mixture models | Three-step and BCH, Bayesian SEM, dynamic SEM, TYPE=COMPLEX |
![]() | Programmers and machine learning researchers | Deep learning, NLP, LLMs, APIs | scikit-learn, transformers, Anthropic, OpenAI, and Gemini SDKs, Google API client libraries |
Programs by research purpose
- Deep learning, NLP, and LLM research. Python If you want to do transformer-based deep learning, NLP, or LLM research through Hugging Face, you need to learn Python programming. Hugging Face’s transformers and Hub client, and the official SDKs for the major language model APIs, are Python libraries, and the documentation and code examples are written in Python.
- Prediction with machine learning. Python R Random forests, gradient boosting, and cross-validated prediction are standard in Python’s scikit-learn and are well supported in R. Stata can run some of these, but the range of models and the documentation are much larger in Python and R.
- Heterogeneous treatment effects and causal machine learning. R Python Stata R’s grf fits causal forests; in Python, EconML estimates conditional average treatment effects and DoubleML implements double machine learning (it also has an R version); Stata users have ddml, described in the Stata Journal in 2024.
- Collecting data from platforms and web services. Python The official client libraries for most platform APIs, such as Google’s client libraries for the YouTube Data API, are written for Python and other general-purpose languages, not for R or Stata.
- Survey data with weights, strata, and clusters. Stata R Stata’s svy prefix applies the sampling weights, strata, and clusters to most estimators, including logistic, multilevel, and count models, and margins works after them. R’s survey package is a solid alternative. Python is the weakest of the three.
- Multilevel models and other clustered data. Stata R Stata’s mixed, melogit, and the other me commands and xtgee cover students in schools, clients in agencies, and repeated measures within people; R’s lme4 and glmmTMB fit the same families of models.
- Quasi-experimental designs and econometrics. Stata R In Stata, csdid and did_multiplegt_dyn for staggered difference-in-differences, honestdid for parallel-trends sensitivity, sdid for synthetic difference-in-differences, reghdfe for many fixed effects, and ivreg2 for instrumental variables. In R, fixest and the did package; Python has linearmodels for panel and instrumental variable models. Several of these exist in both Stata and R, and honestdid in Stata is a port of the R package.
- Decomposing gaps between groups. Stata Ben Jann’s oaxaca for Blinder-Oaxaca decomposition and fairlie for binary outcomes.
- Regression tables and coefficient plots. Stata Ben Jann’s estout (esttab) for tables and coefplot for coefficient plots, along with Stata’s own etable and collect in recent versions.
- Latent class and latent profile analysis. Mplus Mplus, especially when the classes are related to predictors or distal outcomes, since the three-step approaches described by Asparouhov and MuthĂ©n are built in. Stata’s gsem with lclass(), R’s poLCA, and Python’s StepMix, which also implements three-step estimation, fit latent class models in the other programs.
- Structural equation modeling and measurement. Mplus R Mplus for multilevel, Bayesian, and dynamic SEM, with TYPE=COMPLEX for survey data (feature list); R’s lavaan and semTools as free software, including measurement invariance testing, and mirt for item response theory. Stata’s sem and gsem cover many standard models, and Python’s semopy is still limited by comparison.
- Network analysis. R ergm, part of the statnet suite, for statistical network models, and Sacha Epskamp’s qgraph, bootnet, and psychonetrics for networks among symptoms or items.
- Meta-analysis. R Stata Wolfgang Viechtbauer’s metafor in R; Stata’s meta suite covers standard meta-analysis.
- Bayesian multilevel models. R brms fits Bayesian regression models through Stan with formula syntax close to ordinary regression.
- Matching and weighting. R Stata Noah Greifer’s MatchIt, WeightIt, and cobalt in R cover matching, balancing weights, and balance diagnostics; Stata has teffects and the user-written psmatch2.
- Maps and spatial data. R Python R’s sf with tidycensus, or Python’s geopandas.
Python for statistics
Python is excellent for what it was built for, but it is a weak choice as a main statistics program for social science. Its statistical libraries are not designed around econometric estimation, and structural equation modeling is only partly supported. statsmodels covers many standard models, but the survey analysis package samplics now says on its own page that it “is no longer maintained.” When a model is missing, the alternative is to write it yourself from start to finish, which is a different practice from how social science has usually run these models: with an estimator that has been documented, published, and checked by many users.
APIs
APIs come in two kinds for this purpose. For public statistical data, all three programs have good tools, Stata included. Stata reads Federal Reserve data with the built-in import fred, and getcensus loads American Community Survey data from the Census Bureau API. In R, tidycensus by Kyle Walker returns the same data with boundary geometry attached, ready for mapping.
For platform data and AI models, Python is far ahead of Stata and ahead of R. Google’s client libraries for the YouTube Data API cover Python, Java, JavaScript, PHP, and others but not R. The official client libraries for Anthropic, OpenAI, Google Gemini, and the Hugging Face Hub all include Python, and none of them lists R. R users can call several language models through ellmer, a package from Posit, and StataCorp has posted Stata commands for calling ChatGPT, Claude, Gemini, and Grok that call each API from Python, but the code examples and the newest features come in Python first.
Software defaults
The same model run in two programs does not always give the same numbers, and the differences usually come from defaults. In scikit-learn, the LogisticRegression documentation notes that “regularization is applied by default,” so a logistic regression fit with default settings is a penalized model and its coefficients will not match an unpenalized logit from Stata or R. In statsmodels, ordinary least squares does not include an intercept unless you add one, and the OLS documentation says so directly: “An intercept is not included by default and should be added by the user.”
Clustered standard errors are a less obvious case. The standard errors vignette for the R package fixest clusters one regression by firm and reports three different standard errors for the same coefficient: 0.0649 from R’s lm with the sandwich package, 0.0569 from plm, and 0.0633 from Stata’s xtreg, which fixest reproduces. The vignette’s own conclusion is that the small-sample correction “can have a non-negligible impact on the standard-error.” That fixest was written to match xtreg suggests that Stata is still the reference point in econometrics.

If a reviewer reruns your model in another program and gets a different standard error, both of you may be right, and that is a reproducibility problem.
Syntax and reproducibility
Menu-driven programs such as SPSS leave no record of an analysis unless the syntax is saved separately. A syntax file records every step, so someone else, or the same researcher a year later, can rerun the analysis and obtain the same result. This matters more now that generative AI writes much of the code students use. A model can draft a do-file or an R script in seconds, and the only way to know what was actually estimated is to read, run, and keep that code.
My expectation is that reproducibility will become the standard that analyses are judged by. Economics journals already ask authors for a replication package of data and code, and I expect journals in social work and public health to move in the same direction as more of the code comes from AI tools.
Coding skills and generative AI
Writing code by describing what you want to an AI model and accepting what it returns now has a name. Andrej Karpathy called it vibe coding in February 2025, describing a practice in which “I don’t read the diffs anymore,” and limited it to throwaway weekend projects; Collins made it its Word of the Year for 2025. Students reasonably ask whether learning to write code still matters. I think it does, especially for doctoral students.
The evidence on productivity is mixed. In a 2022 experiment with GitHub Copilot, programmers finished a well-defined task 55.8 percent faster, while a 2025 randomized trial by METR found that experienced open-source developers took 19 percent longer with AI tools even though they estimated afterward that the tools had made them about 20 percent faster. The evidence on learning is more consistent. In a randomized study at Anthropic, engineers learning a new Python library with an AI assistant scored 50 percent on a quiz afterward, compared with 67 percent for those who coded by hand, and the largest gap was on debugging, the skill needed to catch errors in AI-written code. A field experiment with high school students found the same pattern in mathematics: students given GPT-4 without guardrails did better on practice problems and 17 percent worse on the exam taken without it.
For a doctoral student, reaching a result is only part of the goal, since learning the process is the training itself. That includes basic syntax, and it includes knowing how the assumptions of a model change when the specification changes. Language models supply their own choices for whatever a prompt leaves unstated. An analysis of prompt underspecification found that models often infer unstated requirements by default but that this behavior “is fragile” across models and prompts. In data analysis, Bertran and colleagues gave the same dataset and hypothesis to many AI analysts and found “substantial dispersion in effect sizes, p-values, and conclusions,” traced to choices in preprocessing, model specification, and inference. A study of Claude Code and Codex on a social policy question found estimates close to a human many-analysts baseline, but a confirmatory prompt moved Claude Code’s verdicts from 10 percent to 90 percent support. A researcher who cannot read the code cannot tell which of these choices was made.
Becoming a researcher also means taking responsibility for your results and being able to explain them. COPE’s position on authorship and AI tools says that authors who use AI in the collection and analysis of data must disclose it and are “fully responsible for the content of their manuscript, even those parts produced by an AI tool.” If you cannot explain an analysis, you do not really know it, and that affects your confidence in your own work. People solving reasoning problems with AI in two studies by Fernandes and colleagues overestimated their own performance, participants with an AI assistant in a security study wrote less secure code while more often believing it was secure, and a survey of knowledge workers found that higher confidence in generative AI went with less critical thinking and higher self-confidence with more. If even the people trained to do the analysis cannot write the code themselves, who will be able to evaluate the code that AI writes?
Learning Stata
Running statistics in R or Python has become very easy, especially with AI assistance, and that might seem to make Stata unnecessary, but I still think learning it is useful. For data analysis, econometrics, and the advanced statistical methods common in social science, Stata gives more consistent results across versions, well documented estimators, and a large set of packages and options written by the methodologists themselves. Typing version at the top of a do-file, according to the Stata manual, “ensures that your do-file or program will continue to run in all future versions of Stata.”
Costs
| Program | Student price (October 2026) | Source |
|---|---|---|
| Stata/BE | $94 a year, or $298 perpetual | Stata student pricing |
| Stata/SE | $179 a year, or $485 perpetual | same |
| Mplus 9.1.1 | $195 for the base program, $350 with the combination add-on | Mplus student pricing |
| R, Python | free |
Many universities license Stata for students. At the University of Michigan, students can receive Stata at no cost on university-managed machines through their unit IT. Mplus has a free demo version that limits the number of variables, which is enough to try the examples before buying.




