Package: emmeans 2.0.4

Julia Piaskowski

emmeans: Estimated Marginal Means, aka Least-Squares Means

Obtain estimated marginal means (EMMs) for many linear, generalized linear, and mixed models. Compute contrasts or linear functions of EMMs, trends, and comparisons of slopes. Plots and other displays. Least-squares means are discussed, and the term "estimated marginal means" is suggested, in Searle, Speed, and Milliken (1980) Population marginal means in the linear model: An alternative to least squares means, The American Statistician 34(4), 216-221 <doi:10.1080/00031305.1980.10483031>.

Authors:Russell V. Lenth [aut, cph], Julia Piaskowski [cre, aut], Balazs Banfai [ctb], Ben Bolker [ctb], Paul Buerkner [ctb], Iago Giné-Vázquez [ctb], Maxime Hervé [ctb], Maarten Jung [ctb], Jonathon Love [ctb], Fernando Miguez [ctb], Hannes Riebl [ctb], Henrik Singmann [ctb], Alexis Derumigny [ctb], Paul Schmidt [ctb]

emmeans_2.0.4.tar.gz
emmeans_2.0.4.zip(r-4.7)emmeans_2.0.4.zip(r-4.6)emmeans_2.0.4.zip(r-4.5)
emmeans_2.0.4.tgz(r-4.6-any)emmeans_2.0.4.tgz(r-4.5-any)
emmeans_2.0.4.tar.gz(r-4.7-any)emmeans_2.0.4.tar.gz(r-4.6-any)
emmeans_2.0.4.tgz(r-4.6-emscripten)
manual.pdf |manual.html
DESCRIPTION |NEWS
card.svg |card.png
emmeans/json (API)

# Install 'emmeans' in R:
install.packages('emmeans', repos = c('https://rvlenth.r-universe.dev', 'https://cloud.r-project.org'))

Bug tracker:https://github.com/rvlenth/emmeans/issues

Pkgdown/docs site:https://rvlenth.github.io

Datasets:

On CRAN:

Conda:

19.35 score 419 stars 216 packages 19k scripts 162k downloads 1.0k mentions 84 exports 4 dependencies

Last updated from:e7aa58c33b. Checks:9 OK. Indexed: yes.

TargetResultTimeFilesSyslog
linux-devel-x86_64OK269
source / vignettesOK321
linux-release-x86_64OK259
macos-release-arm64OK123
macos-oldrel-arm64OK128
windows-develOK287
windows-releaseOK239
windows-oldrelOK266
wasm-releaseOK201

Exports:.all.vars.aovlist.dffun.cmpMM.combine.terms.diag.emm_register.emm_vignette.get.excl.get.offset.hurdle.support.my.vcov.num.key.std.link.labels.zi.supportadd_groupingadd_submodelsas.emm_listas.emmGridas.glhtas.mcmc.emm_listas.mcmc.emmGridas.mcmc.list.emm_listas.mcmc.list.emmGridcomb_facsconsec.emmccontrastdel.eff.emmcdunnett.emmceff_sizeeff.emmcemmemm_basisemm_defaultsemm_exampleemm_optionsemmeansemmipemmip_ggplotemmip_latticeemmobjemtrendsforce_regularget_emm_optionget.lsm.optionhelmert.emmchpd.summaryidentity.emmcinversejoint_testslinfctlsmlsm.optionslsmeanslsmiplsmobjlstrendsmake.meanintmake.symmintmake.tranmean_chg.emmcmeanintmvcontrastmvregridnrmlz.emmcopoly.emmcpairwise.emmcpermute_levelspoly.emmcpwpmpwppqdrgrecover_dataref_gridregridrevpairwise.emmcsplit_facsymminttesttrt.vs.ctrl.emmctrt.vs.ctrl1.emmctrt.vs.ctrlk.emmctukey.emmcwith_emm_optionswtcon.emmc

Dependencies:estimabilitymvtnormnumDerivrlang

Sophisticated models in emmeans
Contents | Linear mixed models (lmer) | System options for lmerMod models | Bias adjustment with random slopes | Adding variables not in fixed model | Models with offsets | Ordinal models | Models fitted using MCMC methods | Bias-adjusted incidence probabilities | Bayesian prediction

Last update: 2026-05-05
Started: 2017-10-12

Quick start guide for emmeans
Contents | The three basic steps | One-factor model | Two factors, no interaction | Two interacting factors | Diagonal comparisons | Interaction contrasts | Three or more factors | Additional options | What you see versus what you get | Common things that can go wrong | Only one mean is obtained -- or fewer than expected | Having trouble with follow-up analyses, and the pairwise ~ ... recipe | Further reading

Last update: 2026-03-30
Started: 2023-01-16

For developers: Extending emmeans
Contents | Introduction | Data example | Supporting rlm | Quick and dirty support | Supporting lqs objects | The recover_data method | Special arguments | Error handling | The emm_basis method | Dissecting emm_basis.lqs | Communication between methods | Hook functions | Re-gridded basis | Exported methods from emmeans | Existing support for rsm objects | The recover_data method | The emm_basis method | A demonstration | Dispatching and restrictions | Exporting and registering your methods | Conclusions

Last update: 2026-03-30
Started: 2018-04-18

Prediction in emmeans
Contents | Focus on reference grids | Need for an SD estimate | Feedlot example | Predictions on particular strata | Predictions with Bayesian models

Last update: 2026-03-30
Started: 2019-06-06

Re-engineering CLDs
Contents | Introduction | Grouping by underlining | Grouping using letters or symbols | Simulated example | Default CLD | Alternative CLDs | Equivalence sets | Significance sets | Conclusions | References

Last update: 2026-03-30
Started: 2022-10-17

Index of vignette topics
Jump to: A B C D E F G H I J K L M N O P Q R S T U V W X Z | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Z

Last update: 2026-02-27
Started: 2018-04-07

Working with messy data
Contents | Issues with observational data | Mediating covariates | Mediating factors and weights | Nuisance factors | Limiting the size of the reference grid | Counterfactuals and G-Computation | Sub-models | Nested fixed effects | Graphs with nesting | Auto-identification of nested factors -- avoid being trapped!

Last update: 2026-02-27
Started: 2017-09-30

Comparisons and contrasts in emmeans
Contents | Pairwise comparisons | Matrix displays | Effect size | Graphical comparisons | Pairwise P-value plots | Compact letter displays (CLDs) | Other contrasts | Normalized contrasts | Formula interface | Custom contrasts and linear functions | Special properties of log (and logit) transformations

Last update: 2025-04-10
Started: 2017-09-30

FAQs for emmeans
Contents | What are EMMs/lsmeans? | What is the fastest way to obtain EMMs and pairwise comparisons? | I wanted comparisons, but all I get is (nothing) | The model I fitted is not supported by emmeans | I have three (or two or four) factors that interact | I have covariate(s) that interact(s) with factor(s) | I have covariate(s) and am fitting a polynomial model | I have transformed covariate(s) | Some "significant" comparisons have overlapping confidence intervals | All my pairwise comparisons have the same P value | emmeans() doesn't work as expected | All or some of the results are NA | If I analyze subsets of the data separately, I get different results | My lsmeans/EMMs are way off from what I expected | Why do I get Inf for the degrees of freedom? | I get exactly the same comparisons for each "by" group | My ANOVA F is significant, but no pairwise comparisons are | I wanted differences, but instead I got ratios (or odds ratios) | I asked for Tukey adjustments, but that's not what I got | emmeans() completely ignores my P-value adjustments | emmeans() gives me pooled t tests, but I expected Welch's t | I want to see more digits | I want to reproduce results from Stata's margins command

Last update: 2025-04-01
Started: 2017-09-30

Basics of estimated marginal means
Contents | Foundations | Emphasis on experimental data | Emphasis on models | Illustration: pigs experiment | Estimated marginal means | The reference grid, and definition of EMMs | More on the reference grid | Other topics | Passing arguments | Transformations | Derived covariates | Non-predictor variables | Graphical displays | Formatting results | Using weights | Multivariate responses | Objects, structures, and methods | P values, "significance", and recommendations | A set of comparisons or well-chosen contrasts is more useful and interpretable than an omnibus F test | Use adjusted P values | It is not necessary to have a significant F test as a prerequisite to doing comparisons or contrasts | Get the model right first | Consider seeking the advice of a statistical consultant | Summary of main points | References | Further reading

Last update: 2024-12-18
Started: 2017-09-30

Confidence intervals and tests in emmeans
Contents | summary(), confint(), and test() | Back-transforming | Multiplicity adjustments | "By" variables | Adjustments across by groups | Simple comparisons | Joint tests | Testing equivalence, noninferiority, and nonsuperiority | Graphics

Last update: 2024-12-18
Started: 2017-09-30

Models supported by emmeans
Quick reference for supported objects and options | Group A -- "Standard" or minimally supported models | Group B -- Beta regression | Group C -- Count models | Group E -- GEE models | Group G -- Generalized linear models and relatives | Group H -- gamlss models | Group I -- Multiple models (via imputation or averaging) | Group K -- gls and lme models | Group L -- lmerMod models | Group M -- Multivariate models | N - Multinomial responses | Group O - Ordinal responses | Group P -- Other packages | Group Q -- Quantile regression | Group S -- Sampling (MCMC) methods | Group V -- aovList objects (also used with afex_aov objects)

Last update: 2024-12-18
Started: 2017-09-30

Transformations and link functions in emmeans
Contents | Overview | Timing is everything | The model is our best guide | Re-gridding | Implied regridding with certain modes | Link functions | Graphing transformations and links | Models having both a response transformation and a link function | Special transformations | Specifying a transformation after the fact | Auto-detected response transformations | Faking a log transformation | Faking other transformations | Revisiting the neuralgia example | Alternative scale | Standardized response | What to do if auto-detection fails | Reverse-engineering a standardized response | Bias adjustment | Pigs example revisited | Response transformations vs. link functions | InsectSprays example | CBPP example

Last update: 2024-12-18
Started: 2017-09-30

Explanations supplement
Contents | Sub-models | A note on multivariate models | Comparison arrows | Examples and tests | Related reading on comparisons | Confounded effects in joint tests | Intricacies of offsets

Last update: 2024-05-04
Started: 2020-05-15

Interaction analysis in emmeans
Contents | Interacting factors | Simple contrasts | Interaction contrasts | Multivariate contrasts | Interactions with covariates | Summary

Last update: 2024-05-04
Started: 2017-09-30

Utilities and options for emmeans
Contents | Updating an emmGrid object | Setting options | Setting and viewing defaults | Optimal digits to display | Startup options | Combining and subsetting emmGrid objects | Accessing results to use elsewhere | Adding grouping factors | Re-labeling or re-leveling an emmGrid

Last update: 2024-05-04
Started: 2017-10-02

Readme and manuals

Help Manual

Help pageTopics
Estimated marginal means (aka Least-squares means)emmeans-package
Convert to and from 'emmGrid' objectsas.emmGrid as.emm_list as.list.emmGrid
Support for MCMC-based estimationas.mcmc.emmGrid as.mcmc.emm_list as.mcmc.list.emmGrid as.mcmc.list.emm_list mcmc-support
Auto Pollution Filter Noiseauto.noise
Compact letter displayscld.emmGrid cld.emm_list
Manipulate factors in a reference gridadd_grouping add_submodels comb_facs permute_levels split_fac
Contrasts and linear functions of EMMscoef.emmGrid contrast contrast.emmGrid pairs.emmGrid weights.emmGrid
Contrast familiesconsec.emmc contrast-methods del.eff.emmc dunnett.emmc eff.emmc emmc-functions helmert.emmc identity.emmc mean_chg.emmc nrmlz.emmc opoly.emmc pairwise.emmc poly.emmc revpairwise.emmc trt.vs.ctrl.emmc trt.vs.ctrl1.emmc trt.vs.ctrlk.emmc tukey.emmc wtcon.emmc
Calculate Cohen effect sizes and confidence bounds thereofeff_size
Support for 'multcomp::glht'as.glht as.glht.emmGrid emm glht-support glht.emmGrid glht.emmlf modelparm.emmwrap
Run or list additional examplesemm_example
The 'emm_list' classas.data.frame.emm_list as.data.frame.summary_eml coef.emm_list confint.emm_list contrast.emm_list emm_list linfct.emm_list pairs.emm_list plot.emm_list print.emm_list str.emm_list summary.emm_list test.emm_list
Set or change emmeans optionsemm_defaults emm_options get_emm_option with_emm_options
Estimated marginal means (Least-squares means)emmeans
The 'emmGrid' classemmGrid-class
Interaction-style plots for estimated marginal meansemmip emmip.default emmip_ggplot emmip_lattice
Construct an 'emmGrid' object from scratchemmobj
Estimated marginal means of linear trendsemtrends
Support functions for model extensions.all.vars .aovlist.dffun .cmpMM .combine.terms .diag .emm_register .emm_vignette .get.excl .get.offset .hurdle.support .my.vcov .num.key .std.link.labels .zi.support emm_basis extending-emmeans recover_data recover_data.call
Feedlot datafeedlot
Fiber datafiber
Summarize an emmGrid from a Bayesian modelhpd.summary
Compute joint tests of the terms in a modeljoint_tests make.meanint make.symmint meanint symmint
Wrappers for alternative naming of EMMsget.lsm.option lsm lsm.options lsmeans lsmip lsmobj lstrends wrappers
Response-transformation extensionsinverse make.tran
Oats data in multivariate formMOats
Models supported in 'emmeans'models
Multivariate contrastsmvcontrast
Multivariate regriddingmvregrid
Neuralgia dataneuralgia
Nutrition datanutrition
Sales of orangesoranges
Effects of dietary protein on free plasma leucine concentration in pigspigs
Plot an 'emmGrid' or 'summary_emm' objectplot.emmGrid plot.summary_emm
Pairwise P-value matrix (plus other statistics)pwpm
Pairwise P-value plotpwpp
Quick and dirty reference gridqdrg qdrg.default
Combine or subset 'emmGrid' objects+.emmGrid force_regular head.emmGrid rbind.emmGrid rbind.emm_list rbind.summary_emm subset.emmGrid tail.emmGrid [.emmGrid
Create a reference grid from a fitted modelref_grid
Reconstruct a reference grid with a new transformation or simulationsregrid
Miscellaneous methods for 'emmGrid' objectslinfct linfct.default print.emmGrid str.emmGrid vcov.emmGrid
Summaries, predictions, intervals, and tests for 'emmGrid' objectsas.data.frame.emmGrid confint.emmGrid predict.emmGrid summary.emmGrid test test.emmGrid [.summary_emm
Unbalanced datasetubds
Dare to be un-"tidy"!untidy
Update an 'emmGrid' objectlevels<-.emmGrid update.emmGrid update.summary_emm
Using 'xtable' for EMMsprint.xtable_emm xtable.emmGrid xtable.summary_emm