hierarch.stats.hierarchical_randomization

hierarch.stats.hierarchical_randomization(data_array: ndarray | DataFrame, treatment_col: int | str, skip: Collection[int] | None = None, bootstraps: int = 100, permutations: int = 1000, random_state: Generator | int | None = None) Generator[ndarray, None, None]

Yields permuted datasets for a hierarchical randomization test.

Parameters:
data_array2D numpy array or pandas DataFrame

Array-like containing both the independent and dependent variables to be analyzed. It’s assumed that the final (rightmost) column contains the dependent variable values.

treatment_colint or str

The index number of the column containing “N samples” to be compared. Indexing starts at 0. If input data is a pandas DataFrame, this can be the column name.

skiplist of ints, optional

Columns to skip in the bootstrap. Skip columns that were sampled without replacement from the prior column, by default None

bootstrapsint, optional

Number of bootstraps to perform, by default 100. Can be set to 1 for a permutation test without any bootstrapping.

permutationsint, optional

Number of permutations to perform PER bootstrap sample. “all” for exact test (only works if there are only two treatments), by default 1000

random_stateint or numpy random Generator, optional

Seedable for reproducibility., by default None

Yields:
Generator[np.ndarray, None, None]

Permuted data for a hierarchical randomization test.