Compute and plot predictions, slopes, marginal means, and comparisons (contrasts, risk ratios, odds ratios, etc.) for over 70 classes of statistical models in R. Conduct linear and non-linear hypothesis tests, as well as equivalence tests using the delta method.
Install the latest CRAN release:
Install the development version:
install.packages( c("marginaleffects", "insight"), repos = c("https://vincentarelbundock.r-universe.dev", "https://easystats.r-universe.dev"))
R completely before moving on.
Parameter estimates are often hard to interpret substantively, especially when they are generated by complex models with non-linear components or transformations. Many applied researchers would rather focus on simple quantities of interest, which have straightforward scientific interpretations. Unfortunately, these estimands (and their standard errors) are tedious to compute. Moreover, the different modeling packages in
R often produce inconsistent objects that require special treatment.
marginaleffects offers a single point of entry to easily interpret the results of over 73 classes of models, using a simple and consistent user interface.
Powerful: It can compute predictions, comparisons (contrasts, risk ratios, etc.), slopes, and conduct hypothesis tests for 73 different classes of models in
- Simple: All functions share a simple and unified interface.
- Documented: Each function is thoroughly documented with abundant examples. The website includes 20,000+ words of vignettes and case studies.
Efficient: Some operations are orders of magnitude faster than with the
marginspackage, and the memory footprint is much smaller.
Valid: When possible, numerical results are checked against alternative software like
- Thin: Few dependencies.
marginaleffectsfollows “tidy” principles and returns objects that work with standard functions like
glance(). These objects are easy to program with and feed to other packages like
- Extensible: Adding support for new models is very easy, often requiring less than 10 lines of new code. Please submit feature requests on Github.
- Active development: Bugs are fixed promptly.
marginaleffects package allows
R users to compute and plot three principal quantities of interest: (1) predictions, (2) comparisons, and (3) slopes. In addition, the package includes a convenience function to compute a fourth estimand, “marginal means”, which is a special case of averaged predictions.
marginaleffects can also average (or “marginalize”) unit-level (or “conditional”) estimates of all those quantities, and conduct hypothesis tests on them.
The outcome predicted by a fitted model on a specified scale for a given combination of values of the predictor variables, such as their observed values, their means, or factor levels. a.k.a. Fitted values, adjusted predictions.
Compare the predictions made by a model for different regressor values (e.g., college graduates vs. others): contrasts, differences, risk ratios, odds, etc.
Predictions of a model, averaged across a “reference grid” of categorical predictors.
Hypothesis & Equivalence
Bayes, Bootstrap, Simulation