Expand description
Statistical tests for pairwise group comparisons.
This crate provides:
one_way_anova— one-way analysis of variance (F-test) with η²/ω² effect sizestukey_hsd— Tukey HSD test (assumes equal variances); any k ≥ 2games_howell— Games-Howell test (does not assume equal variances); any k ≥ 2dunnett— Dunnett’s test (compare treatments against a control)levene_test— Brown-Forsythe/Levene test for equality of variancesptukey_cdf— exact CDF of the studentized range distributionq_critical— critical value lookup (any k ≥ 2, any alpha ∈ (0, 1))dunnett_critical— Dunnett’s critical value lookupparse_csv— load grouped data from CSV (wide format)
All test functions accept any type implementing AsRef<[f64]> for groups,
so you can pass &[Vec<f64>], &[&[f64]], or &[[f64; N]].
§Example
use tukey_test::{one_way_anova, tukey_hsd};
let data = vec![
vec![23.0, 25.0, 21.0, 24.0], // Group A
vec![30.0, 28.0, 33.0, 31.0], // Group B
vec![22.0, 24.0, 20.0, 23.0], // Group C
];
// Step 1: check if there is an overall difference
let anova = one_way_anova(&data).unwrap();
println!("{anova}");
// Step 2: find which pairs differ
let result = tukey_hsd(&data, 0.05).unwrap();
println!("{result}");
for pair in result.significant_pairs() {
println!("Groups {} and {} differ significantly (q = {:.4})",
pair.group_i, pair.group_j, pair.q_statistic);
}Structs§
- Anova
Result - Results of a one-way ANOVA.
- Dunnett
Comparison - A single comparison of a treatment group against the control.
- Dunnett
Result - Full results of a Dunnett’s test.
- Games
Howell Result - Full results of a Games-Howell test.
- Levene
Result - Results of a Levene / Brown-Forsythe test for equality of variances.
- Pairwise
Comparison - A single pairwise comparison between two groups.
- Tukey
Result - Full results of a Tukey HSD test.
Enums§
- Tukey
Error - Errors that can occur during Tukey test operations.
Functions§
- dunnett
- Perform Dunnett’s test (two-sided) comparing each treatment group against a control group.
- dunnett_
critical - Look up the critical value from the Dunnett distribution (two-sided).
- games_
howell - Perform a Games-Howell post-hoc test.
- levene_
test - Test whether group variances are equal (Brown-Forsythe variant, median-based).
- one_
way_ anova - Perform a one-way analysis of variance (ANOVA).
- parse_
csv - Parse CSV data in wide format (each column is a group).
- parse_
csv_ file - Convenience wrapper: parse CSV from a file path.
- ptukey_
cdf - CDF of the studentized range distribution P(Q ≤ q; k, df).
- q_
critical - Look up the critical q value from the studentized range distribution.
- tukey_
hsd - Perform a Tukey HSD test on grouped data.