Standardize a Contrast Table
describe_contrasts.Rd
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.
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
orz
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