# `causalis.shared.confounders_balance`

## Module Contents

### Functions

`confounders_balance` | Compute balance diagnostics for confounders between two treatment groups.

### API

causalis.shared.confounders_balance.confounders_balance(data: causalis.dgp.causaldata.CausalData | causalis.dgp.multicausaldata.MultiCausalData, treatment_d_0: Optional[str] = None, treatment_d_1: Optional[str] = None) → pandas.DataFrame

  Compute balance diagnostics for confounders between two treatment groups.

  Produces a DataFrame containing expanded confounder columns (after one-hot encoding categorical variables if present) with:

  - confounders: name of the confounder

  - mean_d_0: mean value for control group (t=0)

  - mean_d_1: mean value for treated group (t=1)

  - abs_diff: abs(mean_d_1 - mean_d_0)

  - smd: standardized mean difference (Cohen’s d using pooled std)

  - ks_pvalue: p-value for the KS test (rounded to 5 decimal places, non-scientific)

  Parameters

  data : CausalData or MultiCausalData The causal dataset containing the dataframe and confounders. treatment_d_0 : str, optional For MultiCausalData, name of the first treatment column to compare. Mapped to output column `mean_d_0`. treatment_d_1 : str, optional For MultiCausalData, name of the second treatment column to compare. Mapped to output column `mean_d_1`.

  Returns

  pd.DataFrame Balance table sorted by |smd| (descending).