smmargins¶
Stata-style margins for StatsModels:
adjusted predictions, marginal effects, elasticities, and
difference-in-differences — with delta-method, Krinsky–Robb simulation,
or bootstrap standard errors, robust covariance passthrough (HC0–HC3,
cluster, HAC), and simultaneous confidence intervals (Bonferroni, Šidák,
sup-t) — for any fitted model that exposes params, cov_params(),
and predict(params, exog).
Getting started
Tutorials — learning by doing
How-to guides — task-focused recipes
- How to compute robust and cluster-robust standard errors for marginal effects
- How to use Krinsky–Robb simulation for standard errors and confidence intervals
- How to compute bootstrap standard errors with pairs, cluster, or block resampling
- How to compute simultaneous confidence intervals for families of margins
- How to report marginal effects on custom scales and with user-defined transforms
- How to compute subgroup-specific average marginal effects with the over parameter
- How to perform joint Wald tests and pairwise comparisons on marginal effects
- How to compute counterfactual predictions with values, Expr, and newdata
- How to set covariate profiles with
values=,Expr, andnewdata= - How to compute elasticities and semi-elasticities for marginal effects
- How to compute marginal effects for multinomial and ordered outcome models
- How to plot predictions, slopes, and comparisons
- How to verify smmargins results against R marginaleffects
- How to choose between formula mode and raw exog mode
Reference
- API reference
- smmargins.Margins
- smmargins.MarginsResult
- smmargins.DiDResult
- smmargins.WaldResult
- smmargins.Transform
- smmargins.Expr
- smmargins.plot_predictions
- smmargins.plot_slopes
- smmargins.plot_comparisons
- smmargins.transforms.Identity
- smmargins.transforms.Linear
- smmargins.transforms.Exp
- smmargins.transforms.Log
- smmargins.transforms.Logit
- smmargins.transforms.Probit
- smmargins.utils._central_jacobian
- Demos
Explanations — theory and design
- Mathematical motivation
- Why
Exprand thevalues=DSL - Analytic vs. Finite-Difference Jacobians
- Why Patsy Design Matrix Rebuilding Matters
- Prediction Scales and Link Functions
- The Ai & Norton Difference-in-Differences Problem
- Comparing Inference Methods: Delta vs. KR vs. Bootstrap
- Multiple Comparison Adjustments
- Discrete vs. Continuous Variable Detection
- Formula Mode vs. Raw Exog Mode
- Why
Margins.contrastexists: joint covariance for two arms