stratified_contingency_table#
- rojak.turbulence.metrics.stratified_contingency_table(effect_of, on_var, *control_var, sum_over)[source]#
Compute contingency tables stratified by one or more control variables
If a single
control_varis given, the contingency table betweeneffect_ofandon_varis computed assuming the stratification is on the prescence ofcontrol_varand the abscence. In other words, two contingency tables are computed, once on the condition ofcontrol_varand another onnot control_var. If more than onecontrol_varis given, the contingency table betweeneffect_ofandon_varis instead computed once each of the control variables assuming that each represents a specific strata.Given :math`k` strata :math`Z_{1}, dots, Z_{k}` (defined by
control_varas described above), a contingency table is computed for each stratum, as defined as [Agresti2022],\[\begin{split}\begin{array}{c|c|c|c} Z & X & Y = 1 & Y = 0 \\ \hline Z_{1} & X = 1 & n_{111} & n_{011} \\ & X = 0 & n_{101} & n_{001} \\ \hline \vdots & \vdots & \vdots & \vdots \\ \hline Z_{k} & X = 1 & n_{11k} & n_{01k} \\ & X = 0 & n_{10k} & n_{00k} \\ \end{array}\end{split}\]where :math`X` is
effect_ofand :math`Y` ison_var.- Parameters:
effect_of (DataArray) – First binary variable (:math`x` in contingency table)
on_var (DataArray) – Second binary variable (:math`y` in contingency table)
*control_var (DataArray) – One or more binary variables to stratify by (:math`z` in contingency table)
sum_over (str | list[str] | None) – Dimension(s) to sum over to compute the number of observations. If None, it will sum over all dimension in the array
- Returns:
List of
ContingencyTable, one per stratum- Return type: