bayesplain.core.dirichlet_multinomial.cramers_v

bayesplain.core.dirichlet_multinomial.cramers_v(prob_tables)[source]

Cramer’s V for one or many tables of probabilities.

Computed from probabilities rather than counts, so it does not depend on sample size:

\[\phi^2 = \sum_{ij} \frac{(p_{ij} - p_{i\cdot}p_{\cdot j})^2} {p_{i\cdot}p_{\cdot j}}, \qquad V = \sqrt{\frac{\phi^2}{\min(R-1,\, C-1)}}\]

Applied to draws from posterior_cell_draws(), this yields a posterior distribution over association strength – the thing a chi-square test cannot give you.

Parameters:
prob_tables : array_like

Either a single (R, C) table of probabilities summing to 1, or a stack of shape (size, R, C).

Returns:

Cramer’s V, scalar-shaped for a single table and shape (size,) for a stack. Ranges from 0 (exact independence) to 1.

Return type:

ndarray