Skip to contents

This function standardizes a contrast table from model summary statistics, including the estimates, standard errors, confidence intervals, and test statistics. It adjusts column names and formats the results for easy interpretation, providing concise representations of the differences and test results.

Usage

describe_contrasts(raw_contrasts_table)

Arguments

raw_contrasts_table

A contrast table from a model summary, typically containing columns for estimates, standard errors, confidence intervals, and test statistics. This object can either contain asymptotic or confidence limits, which the function will detect and handle accordingly.

Value

A standardized data frame containing:

Contrast

The name of the contrast tested.

Difference±SE [95% CI]

Formatted difference estimates with standard error and confidence intervals.

Test

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

Details

The function checks if the input table contains asymptotic or regular confidence limits (asymp.LCL/asymp.UCL or lower.CL/upper.CL). It also detects whether to use z.ratio or t.ratio for the test statistic. The final table provides a concise summary of the contrasts, including estimates, standard errors, confidence intervals, test statistics, and p-values, all in a human-readable format.

Examples

library(emmeans)
#> Welcome to emmeans.
#> Caution: You lose important information if you filter this package's results.
#> See '? untidy'
model <- lm(Sepal.Length ~ Sepal.Width + Species, data = iris)
contrast_table <- emmeans(model, pairwise ~ Species)$contrasts
result <- describe_contrasts(contrast_table)
print(result)
#>                 Contrast     Difference±SE [95% CI], SMD         t[df], p-value
#> 1    setosa - versicolor    -1.5±0.1 [-1.7, -1.2], -1.08 t[146]=-13.012, <0.001
#> 2     setosa - virginica    -1.9±0.1 [-2.2, -1.7], -1.61 t[146]=-19.465, <0.001
#> 3 versicolor - virginica -0.49±0.09 [-0.7, -0.27], -0.45  t[146]=-5.409, <0.001