This function is a wrapper for emmeans::emmeans() and multcomp::cld() (details here). Based on a given linear model object, it computes estimated marginal means (a.k.a. least-squares means, adjusted means, modelbased means) for specified factors or factor combinations as well as comparisons or contrasts among them. Moreover, it adds the compact letter display to the comparisons/contrasts. Finally, its output is a list with six elements: for the means and their diffs, respectively, (i) a tibble with the results, (ii) the same tibble but in a print-ready format and (iii) an info text summarizing the results.

get_emmeans(
  model,
  specs_string,
  lmer.df = c("Asymptotic", "Satterthwaite", "Kenward-Roger")[3],
  adjust = c("none", "tukey", "bonferroni")[1],
  lang = c("eng", "ger")[1],
  num_accuracy = 0.01,
  sort = c("none", "asc", "desc")[1]
)

Arguments

model

a linear model object. See the list of supported model classes

specs_string

a character vector specifying the names of the predictors over which emmeans are desired

lmer.df

degrees of freedom method. See the list of available methods

adjust

multiplicity adjustment. Follow this link and scroll down o to the “P-value adjustments” heading within the “summary.emmGrid” section for more details on e.g. Fisher’s LSD test, Tukey-test, Bonferroni adjustment etc.

lang

Language for table names and text.

num_accuracy

format the number of digits shown after the decimal separator

sort

sort the levels of the predictors given in specs_string in the output

Details

Here is a discussion on the speed of calculating confidence intervals with different degrees of freedom methods.