Skip to content

Estimation Statistics with DABEST

A t-test tells you whether a difference of zero is hard to reconcile with the data. It does not tell you how large the difference is, and two experiments with the same p-value can disagree by a factor of ten in effect size. Estimation statistics reports the effect itself, with a confidence interval for its uncertainty, and leaves the p-value as a footnote.

DABEST, for data analysis with bootstrap-coupled estimation, puts that idea into one figure. The estimation plot shows every observation on one axis and the bootstrap distribution of the effect size on a second axis, aligned to the first. The R package is dabestr and the Python package is dabest. Both come from the same lab, and the tabs below run them on the same table.

Download il6_secretion.csv into your working directory. The invented table holds one IL-6 concentration in pg/mL for each of 48 independent macrophage cultures: 12 treated with vehicle and 12 with each of three compounds. Each row is a separate culture, so each row is one experimental unit.

The values come from a simulation with known answers. Compound A lowers the median IL-6 by 30 percent, Compound B by 12.5 percent, and Compound C not at all. Real experiments do not supply this answer key, but it helps you judge what the intervals below can and cannot detect.

dabestr exports its own load(), which masks base::load(), so the R code calls it as dabestr::load(). On import, dabest compiles its numba functions and prints two progress lines.

library(dabestr)
library(ggplot2)
il6 <- read.csv("il6_secretion.csv")
groups <- c("Vehicle", "Compound A", "Compound B", "Compound C")
dir.create("outputs", showWarnings = FALSE)
#' Print each contrast of a dabestr effect size with its interval.
#'
#' @param effect An effect size object from mean_diff(), median_diff() or
#' hedges_g().
#' @param interval Either "bca" or "pct", the interval type to print.
#' @return Invisibly, the bootstrap result table of the effect size.
ReportEffect <- function(effect, interval = "bca") {
boot <- effect$boot_result
low <- boot[[paste0(interval, "_ci_low")]]
high <- boot[[paste0(interval, "_ci_high")]]
cat(sprintf("%s vs %s: %.2f [%g%% CI %.2f, %.2f]\n", boot$test_group,
boot$control_group, boot$difference, boot$ci, low, high),
sep = "")
invisible(boot)
}

Summarize each group before any model. The mean and the median of Compound B differ by more than 20 pg/mL, which is a first sign that one effect size can tell a different story from another.

for (group in groups) {
values <- il6$il6_pg_ml[il6$treatment == group]
cat(sprintf("%-10s n = %d, mean = %.1f, median = %.1f\n", group,
length(values), mean(values), median(values)))
}
Vehicle n = 12, mean = 408.1, median = 401.4
Compound A n = 12, mean = 269.8, median = 270.4
Compound B n = 12, mean = 404.9, median = 427.1
Compound C n = 12, mean = 440.2, median = 437.5

Welch’s t-test compares Compound A with vehicle without assuming equal variances. The two-group testing page explains the test itself.

vehicle <- il6$il6_pg_ml[il6$treatment == "Vehicle"]
compound_a <- il6$il6_pg_ml[il6$treatment == "Compound A"]
welch <- t.test(compound_a, vehicle)
cat(sprintf("Welch t = %.3f, df = %.2f, p = %.2g\n", welch$statistic,
welch$parameter, welch$p.value))
cat(sprintf("Mean difference %.2f, 95%% CI [%.2f, %.2f]\n",
mean(compound_a) - mean(vehicle), welch$conf.int[1],
welch$conf.int[2]))
Welch t = -5.386, df = 14.90, p = 7.7e-05
Mean difference -138.32, 95% CI [-193.08, -83.55]

A p-value of 7.7e-05 says that a difference of zero fits these data poorly. It says nothing about how much IL-6 Compound A removed, and a larger experiment can return the same p-value for a much smaller reduction. The second line carries the size: the mean fell by 138.32 pg/mL, and reductions from 83.55 to 193.08 pg/mL are compatible with the data.

load() takes the table, the grouping column, the measurement column, and idx, the groups to compare. The first group in idx is the control, and every effect is the test group minus that control. mean_diff() then draws 5000 bootstrap resamples of each group and computes the bias-corrected and accelerated (BCa) interval of the mean difference.

two_groups <- dabestr::load(il6, x = treatment, y = il6_pg_ml,
idx = c("Vehicle", "Compound A"))
mean_effect <- mean_diff(two_groups)
ReportEffect(mean_effect)
Compound A vs Vehicle: -138.32 [95% CI -188.88, -89.87]

Both packages report the same mean difference, −138.32 pg/mL, because it is the difference of the two sample means. The limits differ: −188.88 to −89.87 in R and −188.19 to −90.80 in Python. Each package draws its own resamples from a fixed seed, so a rerun repeats its own limits, but the two packages never share them.

Both bootstrap intervals are narrower than the Welch interval. The bootstrap treats the spread of 12 cultures as the spread of the population, while the t distribution adds width for having estimated it. With small groups, read a bootstrap interval as slightly optimistic.

dabest_plot() in R and the plot() method in Python draw the estimation plot from the same object.

mean_plot <- dabest_plot(mean_effect)
ggsave("outputs/il6-mean-diff-r.png", mean_plot, width = 6, height = 4.5,
dpi = 150)

Gardner-Altman estimation plot from dabestr. IL-6 values for 12 vehicle and 12 Compound A cultures on the left, and the bootstrap distribution of the mean difference with its 95% interval on the right.

This layout is a Gardner-Altman plot. The left axes show each culture, a shaded bar up to each group mean, and a gapped line for one standard deviation either side of the mean. The right axes float: their zero sits at the vehicle mean, so the dot for the mean difference lines up with the Compound A mean. The filled curve is the bootstrap distribution of the difference, and the vertical line is its 95% interval.

The mean difference keeps the units of the assay, which is what a reader of a cytokine experiment usually wants. Two other effect sizes answer neighboring questions.

  • The median difference is less sensitive to one extreme culture. The BCa correction can be biased for a median, and dabest warns about it, so the code below prints the percentile interval instead.
  • Hedges’ g divides the mean difference by the pooled standard deviation and corrects for small samples. It has no units, which helps when you compare assays on different scales and hides how many pg/mL changed.
median_effect <- median_diff(two_groups)
ReportEffect(median_effect, interval = "pct")
hedges_effect <- hedges_g(two_groups)
ReportEffect(hedges_effect)
Compound A vs Vehicle: -131.00 [95% CI -195.10, -92.55]
Compound A vs Vehicle: -2.12 [95% CI -3.26, -1.02]

The median difference, −131.00 pg/mL, stays close to the mean difference because Compound A has no extreme culture. A resampled median of 12 values is always the average of two observed values, so the bootstrap distribution of the median is lumpy. Its limits move more between R and Python than the limits of the mean difference do.

Hedges’ g is −2.12, so the Compound A mean sits about two pooled standard deviations below vehicle. dabest warns that the upper limit of this interval falls among the ten most extreme bootstrap values, which makes that limit unstable. The two upper limits, −1.02 in R and −0.88 in Python, show the instability.

Compare several compounds with one control

Section titled “Compare several compounds with one control”

A shared-control design puts the control first in idx and lists every test group after it. Each contrast is that group minus vehicle. With more than two groups, the plot switches to the Cumming layout: observations on top and the effect sizes on a separate axis below.

shared_control <- dabestr::load(il6, x = treatment, y = il6_pg_ml,
idx = groups)
shared_effect <- mean_diff(shared_control)
ReportEffect(shared_effect)
shared_plot <- dabest_plot(shared_effect)
ggsave("outputs/il6-shared-control-r.png", shared_plot, width = 7,
height = 6, dpi = 150)
Compound A vs Vehicle: -138.32 [95% CI -188.88, -89.87]
Compound B vs Vehicle: -3.22 [95% CI -84.89, 77.30]
Compound C vs Vehicle: 32.04 [95% CI -37.04, 114.29]

Cumming estimation plot from dabestr. IL-6 values for vehicle and three compounds on the top axes, and the mean difference of each compound from vehicle with its 95% interval on the bottom axes.

Compound A is the only clear effect. The Compound B interval runs from about −85 to +77 pg/mL. It includes zero, and it also includes the true effect of the simulation: a median 50 pg/mL below vehicle. Twelve cultures per group cannot separate that reduction from no change. “Compound B has no effect” would misread this result; the experiment cannot tell. Compound C has no simulated effect, and its interval, about −37 to +114 pg/mL in R, includes zero.

Each interval has 95% coverage for its own contrast. The three intervals together do not have 95% joint coverage, and the chance that at least one misses its true value grows with each compound you add. Decide which contrasts matter before the experiment, as the multiple testing page describes for p-values.

ci sets the coverage of the interval, and resamples sets the number of bootstrap draws. The first changes what the interval claims. The second only changes how precisely the bootstrap finds the interval limits.

ninety <- dabestr::load(il6, x = treatment, y = il6_pg_ml,
idx = c("Vehicle", "Compound A"), ci = 90)
ReportEffect(mean_diff(ninety))
few_draws <- dabestr::load(il6, x = treatment, y = il6_pg_ml,
idx = c("Vehicle", "Compound A"),
resamples = 500)
ReportEffect(mean_diff(few_draws))
Compound A vs Vehicle: -138.32 [90% CI -179.69, -98.57]
Compound A vs Vehicle: -138.32 [95% CI -186.24, -89.96]

The 90% interval is narrower than the 95% interval because it claims less. Report the coverage with the interval, because a reader assumes 95%.

With 500 resamples, the 95% limits move by a few pg/mL from the 5000-resample result. The three Python seeds put the upper limit at −97.08, −92.58 and −86.96, a spread of about 10 pg/mL that comes from the bootstrap and not from the cultures. dabestr fixes its seed internally, so the R tab shows one run. Keep the default of 5000 resamples, and raise it if a limit must be stable to the last digit you report.

float_contrast = FALSE draws a two-group comparison in the Cumming layout. The other arguments set the axis labels, the marker size and transparency, and the palette. dabestr takes a ggsci palette name, and dabest takes a Matplotlib palette name.

custom_plot <- dabest_plot(mean_effect, float_contrast = FALSE,
swarm_label = "IL-6 (pg/mL)",
contrast_label = "Mean difference (pg/mL)",
raw_marker_size = 2, raw_marker_alpha = 0.6,
custom_palette = "jco")
ggsave("outputs/il6-custom-r.png", custom_plot, width = 5, height = 6,
dpi = 150)

Cumming estimation plot of vehicle and Compound A from dabestr, with labeled axes, larger translucent markers, and the jco palette.

Give the effect in the units of the assay, its interval, the software, and the number of experimental units: “Compound A lowered mean IL-6 by 138 pg/mL relative to vehicle (95% BCa bootstrap CI 90 to 189 pg/mL, dabestr 2025.3.15, 12 cultures per group).” The package version belongs in the report because another implementation gives slightly different limits. Add the p-value after the estimate if a journal asks for it.

The bootstrap treats each row as an independent draw. Average technical replicate wells from one culture before the analysis, or model them as in mixed models. Otherwise the interval describes the variation between wells and comes out too narrow for a claim about cultures.

Ho and colleagues, 2019 describe estimation graphics and the DABEST packages that draw them with bootstrap confidence intervals.

Lu and colleagues, 2026 extend estimation graphics to multi-group designs, including several test groups against a shared control.

Efron, 1987 describes the bias-corrected and accelerated bootstrap interval that both packages report by default.

The dabestr basics vignette lists the effect sizes that this page does not use, such as Cohen’s d and Cliff’s delta, and the permutation tests that dabestr reports beside each effect.

The dabestr repeated measures vignette covers paired and repeated designs. Read it before you apply load() to a design with more than one measurement per subject.

The dabestr plot aesthetics vignette lists every plot argument that this page leaves at its default.

The dabest basics tutorial shows the Python interface, including the ci_type argument for percentile intervals in plots.

The Statistics Globe Hub module “Beyond p-Values with dabestr in R” teaches the same topics with a video lecture, the PlantGrowth data, and exercises. The Hub overview lists the other modules of the Hub.

The two-group figure page draws an estimate and its interval with ggplot2 and Matplotlib, without DABEST. The ANOVA page covers the omnibus test that a shared-control estimation plot replaces.