Skip to content

Add ttest_equal_var argument to control t-test variance assumption#194

Merged
tompollard merged 3 commits intomainfrom
tp/issue_193
Apr 10, 2025
Merged

Add ttest_equal_var argument to control t-test variance assumption#194
tompollard merged 3 commits intomainfrom
tp/issue_193

Conversation

@tompollard
Copy link
Owner

@tompollard tompollard commented Apr 10, 2025

This pull request introduces a new ttest_equal_var argument to the TableOne class, allowing users to specify whether equal variances should be assumed when performing t-tests (see: #193).

By default ttest_equal_var=False, which performs Welch’s t-test, a test that does not assume equal variance between groups.

df = pd.DataFrame({
    'group': ['A', 'A', 'A', 'B', 'B', 'B'],
    'x': [1.0, 2.0, 3.0, 20.0, 22.0, 24.0]
})

ttest_equal_var=False

t1 = TableOne(df, columns=['x'], groupby='group', pval=True, ttest_equal_var=False, pval_digits=5)
pval_welch = t1.tableone[('Grouped by group', 'P-Value')].iloc[1]

# pval_welch == "0.00065"

ttest_equal_var=True

t2 = TableOne(df, columns=['x'], groupby='group', pval=True, ttest_equal_var=True, pval_digits=5)
pval = t2.tableone[('Grouped by group', 'P-Value')].iloc[1]

# pval == "0.00010"

@tompollard tompollard merged commit 3258e89 into main Apr 10, 2025
3 checks passed
@tompollard tompollard deleted the tp/issue_193 branch April 10, 2025 02:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant