Skip to content

synaptome.hypotheses

synaptome.hypotheses

Hypothesis tests applied to questions: a registry of tests (what each needs of a question's design, its engine function, its default effect sizes) and the runner behind q.test(...) (DESIGN.md section 6).

Test dataclass

One hypothesis test.

Attributes:

Name Type Description
name str
answers tuple[str, ...]

The question kinds it answers ("compare", "compare_along", "distribution").

designs tuple[str, ...]

"paired" and / or "independent"; "any" also allows a question without a factor.

scales tuple[str, ...] | None

Scales of the analysed values it accepts; None: those of its estimator (bootstrap).

binary bool | None

True: needs a binary outcome; False: refuses one; None: either.

function callable | None

Pairwise: f(x, y, alternative=, offset=, **params) -> engine.StatResult on one pair's samples (paired: matched arrays); None for bootstrap, which reads its estimator's draws. Omnibus: f(wide) (paired, units x groups) or f(samples). Cluster: engine.cluster_permutation. Normality: f(x).

params dict

Further parameters and their defaults (zero_method, n_boot, ...).

effect_sizes tuple[str, ...]

Effect sizes reported by default, computed through synaptome.estimates (those the design doesn't allow are left out). Any pair estimator the design allows can be asked instead.

ordered_unit str

"refuse": assumes independent observations, refused with an ordered unit unless assume_independent=True; "only": made for an ordered unit (ttest_ess).

offset bool

Whether it takes an offset (a margin the difference is tested against).

result str

The result it produces: "pairwise", "omnibus", "cluster" or "normality".

min_groups int

Omnibus tests: the fewest groups they need (Friedman: 3).

correction str

Default correction of its rows ("holm"; "none" for normality, a diagnostic).

description str

get(name)

The registry entry for name; an unknown name lists the tests.

compute_test(question, name, alternative='two-sided', offset=None, effect_sizes=None, correction=None, alpha=0.05, assume_independent=False, **params)

Runs test name on question. See Question.test for the parameters.

Returns:

Type Description
(table, method, extras): tuple

Pairwise: one row per pair (a - b): statistic, p, corrected p, verdict, counts and effect sizes. Omnibus: one row. Cluster: one row per cluster of each pair. Normality: one row per group or pair. method records the test and every setting used; extras holds further tables (draws; pairs, curve and null for clusters).

Raises:

Type Description
ValueError

When the test doesn't suit the question (kind, design, scale, binary outcome, ordered unit, number of groups) or a setting is invalid, naming what to use instead.