Skip to contents

This function standardizes a table of estimated marginal means (EMMs) from model summary statistics. It reformats the EMM estimates, standard errors, confidence intervals, and test statistics into a human-readable format.

Usage

describe_emmeans(raw_emmeans_table)

Arguments

raw_emmeans_table

A table of estimated marginal means from a model summary, typically containing columns for EMM estimates, standard errors, confidence intervals, and test statistics. The function will detect if the table contains asymptotic or regular confidence limits.

Value

A standardized data frame containing:

Estimate±SE [95% CI]

Formatted estimates with standard errors and 95% confidence intervals.

Test

Formatted test statistic (either t or z statistic), degrees of freedom, and p-value.

Details

This function checks whether the input table includes asymptotic or regular confidence limits (asymp.LCL/asymp.UCL or lower.CL/upper.CL) and whether it should use z.ratio or t.ratio for the test statistic. It processes the raw table and returns a user-friendly summary with formatted estimates and test statistics.

Examples


library(emmeans)
model <- lm(Sepal.Length ~ Sepal.Width + Species, data = iris)
contrast_table <- emmeans(model, ~Species)
result <- describe_emmeans(contrast_table)
print(result)
#>      Species    Estimate±SE [95% CI], SMD         t[df], p-value
#> 1     setosa 4.71±0.07 [4.56, 4.85], 5.31  t[146]=64.131, <0.001
#> 2 versicolor  6.17±0.07 [6.03, 6.3], 7.39  t[146]=89.294, <0.001
#> 3  virginica  6.65±0.06 [6.53, 6.78], 8.8 t[146]=106.365, <0.001