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

ttest

Submodule causalis.scenarios.classic_rct.inference.ttest 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.ttest.ttest

ttest

Perform a Welch two-sample t-test comparing outcomes between groups.

The Welch t-test (also known as the unequal variances t-test) is used to test the hypothesis that two populations have equal means. It is more robust than Student’s t-test when the two samples have unequal variances and/or unequal sample sizes.

Notes

The Welch t-statistic is calculated as:

t=Yˉ1Yˉ0s12n1+s02n0t = \frac{\bar{Y}_1 - \bar{Y}_0}{\sqrt{\frac{s_1^2}{n_1} + \frac{s_0^2}{n_0}}}

The degrees of freedom $\nu$ are approximated using the Welch-Satterthwaite equation:

ν(s12n1+s02n0)2(s12/n1)2n11+(s02/n0)2n01\nu \approx \frac{\left(\frac{s_1^2}{n_1} + \frac{s_0^2}{n_0}\right)^2} {\frac{(s_1^2/n_1)^2}{n_1-1} + \frac{(s_0^2/n_0)^2}{n_0-1}}

For the relative difference (percent lift), the variance is estimated using the Delta method:

Var(Yˉ1Yˉ0)1Yˉ02Var(Yˉ1)+Yˉ12Yˉ04Var(Yˉ0)Var\left(\frac{\bar{Y}_1}{\bar{Y}_0}\right) \approx \frac{1}{\bar{Y}_0^2} Var(\bar{Y}_1) + \frac{\bar{Y}_1^2}{\bar{Y}_0^4} Var(\bar{Y}_0)

Examples

Parameters

dataCausalData

The CausalData object containing treatment and outcome variables.

alphafloat, default 0.05

The significance level for calculating confidence intervals.

Returns

Dict[str, Any]

A dictionary containing: - p_value: Welch t-test p-value. - absolute_difference: $\bar{Y}_1 - \bar{Y}_0$. - absolute_ci: (lower, upper) CI for absolute difference. - relative_difference: Percent change relative to control. - relative_se: Delta-method standard error for the relative difference. - relative_ci: (lower, upper) CI for relative difference.

Canonical target

causalis.scenarios.classic_rct.inference.ttest.ttest

Sections

NotesParametersReturnsExamples
Link to this symbol