causalis.scenarios.classic_rct.inference.conversion_ztest

Two-proportion z-test

Compares conversion rates between treated (D=1) and control (D=0) groups. Returns p-value, absolute/relative differences, and their confidence intervals

Module Contents

Functions

conversion_ztest

Perform a two-proportion z-test on a CausalData object with a binary outcome (conversion).

API

causalis.scenarios.classic_rct.inference.conversion_ztest.conversion_ztest(data: causalis.dgp.causaldata.CausalData, alpha: float = 0.05, ci_method: Literal[newcombe, wald_unpooled, wald_pooled] = 'newcombe', se_for_test: Literal[pooled, unpooled] = 'pooled') Dict[str, Any]

Perform a two-proportion z-test on a CausalData object with a binary outcome (conversion).

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). ci_method : {“newcombe”, “wald_unpooled”, “wald_pooled”}, default “newcombe” Method for calculating the confidence interval for the absolute difference. “newcombe” is the most robust default for conversion rates. se_for_test : {“pooled”, “unpooled”}, default “pooled” Method for calculating the standard error for the z-test p-value. “pooled” (score test) is generally preferred for testing equality of proportions.

Returns

Dict[str, Any] A dictionary containing: - p_value: Two-sided p-value from the z-test - absolute_difference: Difference in conversion rates (treated - control) - absolute_ci: Tuple (lower, upper) for the absolute difference CI - relative_difference: Percentage change relative to control rate - relative_ci: Tuple (lower, upper) for the relative difference CI (delta method)

Raises

ValueError If treatment/outcome are missing, treatment is not binary, outcome is not binary, groups are empty, or alpha is outside (0, 1).