BCompare groups · Guide test 283
Two one sided tests procedure or TOST
Tests whether an effect lies within prespecified lower and upper equivalence margins.
Do it in CodeSplash
In the app, set it up in Analyze with this method:
- Equivalence and minimal-effect tests (TOST) — Is an effect small enough to be practically equivalent to zero, or large enough to matter?
In Equivalence and minimal-effect tests (TOST), choose Test = t tests (means).
Do it in CodeSplash Run this test on your own data, in Python or R.
Bench
Change the design, drag the data, move α. The statistic, its reference distribution and the verdict follow.
Bench · Two one-sided tests (TOST)
The population mean the data come from.
The value H₀ says the mean equals.
Bounds at ± this margin, fixed before seeing the data (the smallest effect that would matter).
Your data
Drag a point or use ↑/↓ to change itIf H₀ were true
- The reference: how t varies across samples when H₀ is true (the one-sided test that decides: min(t_L, −t_U), whose upper tail is max(p_L, p_U)).
- Your statistic, from the data above.
- The p-value: the area at least as extreme as yours (p = .001).
- The hatched rejection region at α = .050: statistics landing here reject H₀.
The estimate against the bounds
Bar: the 90% interval (1 − 2α), the TOST counterpart. Shaded: where the effect must lie to reject H₀. The whole interval sits inside the bounds: compatible with an effect too small to matter.
The formula
With your numbers
- the test against the lower bound (upper tail)
- the test against the upper bound (lower tail)
- the deciding test: its upper tail is max(p_L, p_U), the shaded area
The verdict
t(39) = 3.17, p = .001
p ≤ α = .050: reject H₀
Both one-sided tests must reject: the (1 − 2α) interval inside the bounds. A non-significant ordinary t test is not evidence of equivalence; set the bounds before seeing the data.
- Statistic
- 3.170
- p-value
- 0.0015
Two one-sided tests (TOST) on Sample: n = 40: t(39) = 3.17, p = .001. The p-value is below α = .050, so the data are hard to reconcile with H₀.
Question and hypotheses
H0: θ≤L or θ≥U; H1: L<θ<U (equivalence).
Assumptions
Prespecified scientifically justified bounds L<U; a valid estimator/SE and reference distribution for θ; study design assumptions of the underlying test.
Formula
Parameters and notation
pL tests θ≤L against θ>L; pU tests θ≥U against θ<U. For t inference reject when tL>t1−α,ν and tU<−t1−α,ν.
Structure of the method
Form two boundary tests for the union null θ≤L or θ≥U and reject equivalence only when both reject at alpha. This intersection–union structure yields p_TOST=max(p_lower,p_upper); it does not require halving alpha for the two boundary tests. The compatible two-sided confidence level is 1−2alpha.
Estimated and nuisance parameters
Estimate the effect and the standard error required by its sampling model. In the baseline one-sample example, these are mean difference from five and the sample SD divided by sqrt(n). Equivalence bounds are scientific design inputs, not quantities fitted to the observed confidence interval.
Settings and design choices
Prespecify raw-unit or standardized margins, sidedness, alpha and the underlying estimator. A raw-unit bound and a standardized effect bound define different targets; using an estimated SD to translate between them needs appropriate inference. The example’s unused y vector does not make it a two-sample test.
Fitting and adaptation
There is no fine-tuning. Plan sample size for a plausible true effect and variance within the scientifically defensible interval. Fit the chosen model and inspect both boundary results and the confidence interval. If the sampling model changes, use the corresponding valid boundary tests rather than reusing t degrees of freedom.
Sensitivity and robustness
Equivalence can fail because estimates lie outside the margins or because precision is insufficient; distinguish those situations. Large n makes even small departures detectable but does not justify changing margins. Outliers, clustered observations and model misspecification affect the interval. Equivalence of a mean is not equivalence of complete distributions.
How to use and calibrate
Both one-sided tests must reject at α; equivalently the matching 100(1−2α)% confidence interval lies entirely inside (L,U).
Example application
Demonstrate that a difference is smaller than prespecified practically important bounds.
Interpretation and pitfalls
Watch out
Failure to reject a zero-difference test does not establish equivalence. Bounds cannot be chosen to fit the observed interval.
What changed in edition 2
- New sections: structure of the method, estimated and nuisance parameters, settings and design choices, fitting and adaptation, sensitivity and robustness.
Python and R
Bounds −0.5 and +0.5 are prespecified in raw measurement units (around reference mean 5 for the one-sample example). Both one-sided p-values must be below .05; non-significance of an ordinary difference test is not equivalence.
Validated — Executed successfully in the validation environment · needs numpy, scipy
import numpy as np
from scipy import stats
rng = np.random.default_rng(2026)
x = np.array([4.2,5.1,5.4,4.8,6.0,5.8,4.9,5.6,6.2,5.0])
y = np.array([4.0,4.4,4.8,5.0,5.1,4.3,4.7,4.6,5.2,4.9])
lo=-.5;hi=.5
a=stats.ttest_1samp(x,5+lo,alternative="greater");b=stats.ttest_1samp(x,5+hi,alternative="less")
p_tost=max(a.pvalue,b.pvalue);print(a.pvalue,b.pvalue,p_tost,p_tost<.05)
Output
0.0013068141065884246 0.16517144608628667 0.16517144608628667 False
Validated — Executed successfully in the validation environment · needs Base/standard library
x <- c(4.2,5.1,5.4,4.8,6.0,5.8,4.9,5.6,6.2,5.0)
y <- c(4.0,4.4,4.8,5.0,5.1,4.3,4.7,4.6,5.2,4.9)
lo<--.5;hi<-.5
a<-t.test(x,mu=5+lo,alternative="greater");b<-t.test(x,mu=5+hi,alternative="less")
print(c(p_lower=a$p.value,p_upper=b$p.value,p_TOST=max(a$p.value,b$p.value),equivalent=max(a$p.value,b$p.value)<.05))
Output
p_lower p_upper p_TOST equivalent 0.001306814 0.165171446 0.165171446 0.000000000
Sources
- TOSTER — TOSTER · TOSToneAuthor documentation/source reviewed: TOSTER 0.8.6.search.r-project.org
- TOSTonesearch.r-project.org
- Statistics guide v4 (historical):
- R: Executed successfully in the validation environment
- Reference's record:
- Edition 2 review: Python: executed · R: not executed (Rscript unavailable). Python: Ran in the reference's review, on this exact code. R: Reviewed but not run: R wasn't available to the reference's authors.
From the CodeSplash statistics guide (v4), entry 283, updated from the reference's edition 2 (reviewed 14 November 2026) as STAT283.