vincentarelbundock/marginaleffects

R package to compute and plot predictions, slopes, marginal means, and comparisons (contrasts, risk ratios, odds, etc.) for over 100 classes of statistical and ML models. Conduct linear and non-linear hypothesis tests, or equivalence tests. Calculate uncertainty estimates using the delta method, bootstrapping, or simulation-based inference

marginaleffects – Turning Model Output into Insight

What it ismarginaleffects is an open‑source library for R and Python that streamlines the interpretation of statistical and machine learning models. It lets you go from raw model coefficients to concrete, human‑readable quantities such as predicted values, contrasts, risk ratios, marginal effects (partial derivatives), and hypothesis‑test results.

Why it matters – Modern data analysis often involves dozens of model types (linear regression, GLMs, tree‑based learners, regularized models, etc.). While the models can be fit with existing packages, extracting meaningful summaries is tedious and error‑prone. marginaleffects provides a consistent, unified API that works across 100+ model classes, so analysts can spend time on insight rather than bookkeeping.

Key capabilities

  • Predictions – point forecasts, confidence intervals, and prediction intervals for any supported model.
  • Comparisons / contrasts – compute differences, risk ratios, odds ratios, and other effect measures between groups or scenarios.
  • Slopes & marginal effects – obtain partial derivatives, average marginal effects, and conditional effects for both linear and non‑linear models.
  • Hypothesis testing – perform Wald tests, likelihood‑ratio tests, and bootstrap‑based inference on derived quantities.
  • Cross‑language support – the same high‑level functions are available in both R and Python, facilitating reproducible workflows.

Documentation & learning resources – The package website (marginaleffects.com) hosts full reference docs, examples, and a free HTML version of the companion book Model to Meaning, which walks users through the conceptual framework and practical usage.

Who should use it – Data scientists, statisticians, economists, and any analyst who builds predictive or explanatory models and needs to communicate the results to non‑technical stakeholders.


The project is a genuine software tool for interpreting statistical and machine‑learning models, fitting squarely within the AI/ML ecosystem.

Related

  • Project
  • Project
  • Project
  • Project
  • Project