causalis.scenarios.classic_rct.inference.conversion_ztest.conversion_ztestconversion_ztest
Perform a two-proportion z-test on a CausalData object with a binary outcome.
The z-test for proportions is used to compare the conversion rates of two independent groups. It assumes that the number of successes and failures in each group is sufficiently large (typically $n \cdot p > 5$ and $n \cdot (1-p) > 5$).
Notes
The z-statistic for testing $H_0: p_1 = p_0$ is calculated as:
By default (se_for_test="pooled"), the pooled standard error is used:
where $\hat{p} = \frac{x_1 + x_0}{n_1 + n_0}$ is the pooled proportion.
Confidence intervals for the difference $p_1 - p_0$ can be calculated using several methods. The “newcombe” method (Newcombe’s hybrid score interval) is generally recommended as it performs better than the Wald interval when proportions are near 0 or 1.
Examples
Parameters
- dataCausalData
The CausalData object containing treatment and outcome variables.
- alphafloat, default 0.05
The significance level for calculating confidence intervals.
- ci_method{“newcombe”, “wald_unpooled”, “wald_pooled”}, default “newcombe”
Method for calculating the confidence interval for the absolute difference.
- se_for_test{“pooled”, “unpooled”}, default “pooled”
Method for calculating the standard error for the z-test p-value.
Returns
A dictionary containing: - p_value: Two-sided p-value from the z-test. - absolute_difference: Difference in conversion rates ($p_1 - p_0$). - absolute_ci: (lower, upper) CI for the absolute difference. - relative_difference: Percentage change relative to control. - relative_ci: (lower, upper) CI for the relative difference (delta method).
Canonical target
causalis.scenarios.classic_rct.inference.conversion_ztest.conversion_ztest
Sections