| dunnett_test | R Documentation |
Performs Dunnett's test for comparing each of several treatment
groups against a single control (reference) group. Unlike all-pairwise
post-hoc tests, Dunnett's procedure controls the family-wise error rate over
only the k - 1 treatment-vs-control comparisons, using the exact
multivariate-t distribution (which accounts for the correlation between the
comparisons that share the control group).
This is a pipe-friendly wrapper around emmeans::emmeans() +
emmeans::contrast() (with adjust = "mvt"), so the
emmeans package must be installed. The results match
DescTools::DunnettTest() and multcomp::glht(..., mcp(... =
"Dunnett")).
See the Datanovia tutorial One-Way ANOVA in R for a worked walkthrough.
dunnett_test(
data,
formula,
ref.group = NULL,
conf.level = 0.95,
detailed = FALSE
)
data |
a data.frame containing the variables in the formula. |
formula |
a formula of the form |
ref.group |
a character string specifying the reference (control) group.
Each remaining group level is compared against this group. If |
conf.level |
confidence level of the (simultaneous) confidence intervals. |
detailed |
logical value. Default is FALSE. If TRUE, a detailed result is shown. |
a data frame with some of the following columns:
.y.: the outcome variable used in the test.
group1,group2: the compared groups; group1 is the control
(reference) and group2 is the treatment, consistent with the
ref.group convention of t_test()/wilcox_test()/
dunn_test()/emmeans_test().
n1,n2: sample sizes of
the control and treatment groups.
estimate: the estimated mean
difference group1 - group2 (control minus treatment).
conf.low,conf.high: simultaneous confidence interval for the
difference.
statistic: the t-statistic.
df:
degrees of freedom.
p.adj: the Dunnett-adjusted p-value.
method: the statistical test used.
p.adj.signif: the
significance level of the adjusted p-value.
The estimate, confidence
interval, se and method columns are returned only when detailed =
TRUE.
The returned object has an attribute called args, which is a list holding the test arguments.
Dunnett, C. W. (1955) A multiple comparison procedure for comparing several treatments with a control. Journal of the American Statistical Association, 50, 1096-1121.
tukey_hsd(), games_howell_test(),
emmeans_test()
The Datanovia tutorial: One-Way ANOVA in R.
if (requireNamespace("emmeans", quietly = TRUE)) {
# Compare each dose to the control dose ("0.5")
ToothGrowth %>% dunnett_test(len ~ dose)
# Detailed output (estimate + simultaneous confidence interval)
ToothGrowth %>% dunnett_test(len ~ dose, detailed = TRUE)
# Grouped data
ToothGrowth %>%
group_by(supp) %>%
dunnett_test(len ~ dose)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.