#statistics #p-value

adjustp

A crate to handle different p-value adjustments

5 releases

0.1.4 Aug 23, 2022
0.1.3 Aug 20, 2022
0.1.2 Aug 19, 2022
0.1.1 Aug 19, 2022
0.1.0 Aug 19, 2022

#361 in Science

Download history 54/week @ 2023-05-20 22/week @ 2023-05-27 22/week @ 2023-06-03 9/week @ 2023-06-10 36/week @ 2023-06-17 25/week @ 2023-06-24 77/week @ 2023-07-01 41/week @ 2023-07-08 16/week @ 2023-07-15 19/week @ 2023-07-22 10/week @ 2023-07-29 8/week @ 2023-08-05 16/week @ 2023-08-12 6/week @ 2023-08-19 14/week @ 2023-08-26 17/week @ 2023-09-02

53 downloads per month
Used in 2 crates

MIT license

16KB
308 lines

adjustp

Summary

This is a crate to perform pvalue adjustments for multiple hypothesis tests and is inspired by the R function p.adjust.

There are currently only three methods available: Bonferroni, Benjamini-Hochberg, and Benjamini-Yekutieli.

This crate gives a single interface for each of these multiple hypothesis corrections and does not expect the p-values to be presorted before calculating.

Usage

The main interface for the tests is through the adjust function, which takes a slice of f64 and a Procedure. If you are using ndarray you can use this easily with the .as_slice() function.

Basic Usage

Here's an example for a Bonferroni correction.

use adjustp::{adjust, Procedure};

let pvalues = vec![0.1, 0.2, 0.3, 0.4, 0.1];
let qvalues = adjust(&pvalues, Procedure::Bonferroni);
assert_eq!(qvalues, vec![0.5, 1.0, 1.0, 1.0, 0.5]);

And another example for a BenjaminiHochberg adjustment.

use adjustp::{adjust, Procedure};

let pvalues = vec![0.1, 0.2, 0.3, 0.4, 0.1];
let qvalues = adjust(&pvalues, Procedure::BenjaminiHochberg);
assert_eq!(qvalues, vec![0.25, 0.33333333333333337, 0.375, 0.4, 0.25]);

And another example for a BenjaminiYekutieli adjustment.

use adjustp::{adjust, Procedure};

let pvalues = vec![0.1, 0.2, 0.3, 0.4, 0.1];
let qvalues = adjust(&pvalues, Procedure::BenjaminiYekutieli);
assert_eq!(qvalues, vec![0.5708333333333333, 0.7611111111111111, 0.8562500, 0.91333333333333333, 0.5708333333333333]);

No runtime deps