Skip to content
Submodule
causalis.scenarios.classic_rct.inference.conversion_ztest

conversion_ztest

Submodule causalis.scenarios.classic_rct.inference.conversion_ztest with no child pages and 1 documented members.

Functions

Jump directly into the documented functions for this page.

1 items
function
causalis.scenarios.classic_rct.inference.conversion_ztest.conversion_ztest

conversion_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:

z=p^1p^0SEz = \frac{\hat{p}_1 - \hat{p}_0}{SE}

By default (se_for_test="pooled"), the pooled standard error is used:

SEpooled=p^(1p^)(1n1+1n0)SE_{pooled} = \sqrt{\hat{p}(1-\hat{p})\left(\frac{1}{n_1} + \frac{1}{n_0}\right)}

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

Dict[str, Any]

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

NotesParametersReturnsExamples
Link to this symbol