R package emmeans: Estimated marginal means

Features

Estimated marginal means (EMMs, previously known as least-squares means in the context of traditional regression models) are derived by using a model to make predictions over a regular grid of predictor combinations (called a reference grid). These predictions may possibly be averaged (typically with equal weights) over one or more of the predictors. Such marginally-averaged predictions are useful for describing the results of fitting a model, particularly in presenting the effects of factors. The emmeans package can easily produce these results, as well as various graphs of them (interaction-style plots and side-by-side intervals).

Model support

Versions and installation

remotes::install_github("rvlenth/emmeans", dependencies = TRUE, build_opts = "")

### To install without vignettes (faster):
remotes::install_github("rvlenth/emmeans")

Note: If you are a Windows user, you should also first download and install the latest version of Rtools.

For the latest release notes on this development version, see the NEWS file

Interview with an erstwhile expert

In February, 2024, I interviewed ChatGPT (version 3.5) about the emmeans package. Some things it did better than others. Here’s the conversation.

Supersession plan

The developer of emmeans continues to maintain and occasionally add new features. However, none of us is immortal; and neither is software. I have thought of trying to find a co-maintainer who could carry the ball once I am gone or lose interest, but the flip side of that is that the codebase is not getting less messy as time goes on – why impose that on someone else? So my thought now is that if at some point, enough active R developers want the capabilities of emmeans but I am no longer in the picture, they should feel free to supersede it with some other package that does it better. All of the code is publicly available on GitHub, so just take what is useful and replace what is not.

Note: emmeans supersedes the package lsmeans. The latter is just a front end for emmeans, and in fact, the lsmeans() function itself is part of emmeans.