causalis.scenarios.classic_rct.inference.ttest.ttestttest
Perform a Welch two-sample t-test comparing outcomes between treated (D=1) and control (D=0) groups.
Returns
- p_value: Welch t-test p-value for H0: E[Y|D=1] - E[Y|D=0] = 0 - absolute_difference: treatment_mean - control_mean - absolute_ci: (lower, upper) CI for absolute_difference using Welch df - relative_difference: signed percent change = 100 * (treatment_mean / control_mean - 1) - relative_se: delta-method SE of relative_difference (percent scale) - relative_ci: (lower, upper) CI for relative_difference using delta method (+ Satterthwaite df)
Notes
Delta method for relative percent change: r_hat = 100 * (Ybar1/Ybar0 - 1)
With independent groups and CLT: Var(Ybar1) ≈ s1^2/n1 Var(Ybar0) ≈ s0^2/n2 Cov(Ybar1, Ybar0) ≈ 0
Gradient of g(a,b)=a/b - 1 is (1/b, -a/b^2), so: Var(r_hat/100) ≈ (1/Ybar0)^2 * (s1^2/n1) + (Ybar1/Ybar0^2)^2 * (s0^2/n2)
CI uses t-critical with Satterthwaite df; falls back to z if df is invalid. If control_mean is near 0, relative stats are undefined/unstable and return inf/nan sentinels.
Canonical target
causalis.scenarios.classic_rct.inference.ttest.ttest
Sections