causalis.scenarios.classic_rct.inference.bootstrap_diff_in_means

Bootstrap difference-in-means inference.

This module computes the ATE-style difference in means (treated - control) and provides:

  • Two-sided p-value using a normal approximation with bootstrap standard error.

  • Percentile confidence interval for the absolute difference.

  • Relative difference (%) and corresponding CI relative to control mean.

Module Contents

Functions

bootstrap_diff_means

Bootstrap inference for difference in means between treated and control groups.

API

causalis.scenarios.classic_rct.inference.bootstrap_diff_in_means.bootstrap_diff_means(data: causalis.dgp.causaldata.CausalData, alpha: float = 0.05, n_simul: int = 10000, *, batch_size: int = 512, seed: Optional[int] = None, index_dtype=np.int32) Dict[str, Any]

Bootstrap inference for difference in means between treated and control groups.

This function computes the ATE-style difference in means (treated - control) and provides a two-sided p-value using a normal approximation with bootstrap standard error, a percentile confidence interval for the absolute difference, and relative difference with its corresponding confidence interval.

Parameters

data : CausalData The CausalData object containing treatment and outcome variables. alpha : float, default 0.05 The significance level for calculating confidence intervals (between 0 and 1). n_simul : int, default 10000 Number of bootstrap resamples. batch_size : int, default 512 Number of bootstrap samples to process per batch. seed : int, optional Random seed for reproducibility. index_dtype : numpy dtype, default np.int32 Integer dtype for bootstrap indices to reduce memory usage.

Returns

Dict[str, Any] A dictionary containing: - p_value: Two-sided p-value using normal approximation. - absolute_difference: The absolute difference (treated - control). - absolute_ci: Tuple of (lower, upper) bounds for the absolute difference CI. - relative_difference: The relative difference (%) relative to control mean. - relative_ci: Tuple of (lower, upper) bounds for the relative difference CI (delta method).

Raises

ValueError If inputs are invalid, treatment is not binary, or groups are empty.