The One-Question Answer
Ask this: Is your outcome variable categorical (counts in groups) or continuous (measured numbers)? If categorical → Chi-Square test. If continuous → T-test. This single question settles the choice in most research scenarios.
The Chi-Square test and the T-test both evaluate whether a real difference or relationship exists in your data. They differ in what kind of "difference" they measure. The Chi-Square test counts how often observations fall into categories and asks whether those counts match what you'd expect by chance. The T-test measures numerical values and asks whether the average of those values differs between groups or from a target.
Before diving into formulas and assumptions, the table below gives you the complete comparison at a glance:
Chi-Square Test vs T-Test: Complete Comparison
| Feature | Chi-Square Test (χ²) | T-Test (t) |
|---|---|---|
| Data type | Categorical (nominal or ordinal counts) | Continuous (interval or ratio) |
| What it compares | Observed vs. expected frequencies | Group means or mean vs. a fixed value |
| Parametric? | No — nonparametric | Yes — parametric |
| Distribution assumption | None for the population | Normal distribution (or n > 30) |
| Typical output | χ² statistic, degrees of freedom, p-value | t statistic, degrees of freedom, p-value |
| Number of groups | Two or more categories | One or two groups |
| Effect size measure | Cramér's V, phi (φ) | Cohen's d |
| Minimum expected frequency | ≥ 5 per cell | No frequency requirement |
| Inventor | Karl Pearson (1900) | William Sealy Gosset ("Student", 1908) |
| Software function (R) | chisq.test() | t.test() |
| Software function (Python) | scipy.stats.chi2_contingency() | scipy.stats.ttest_ind() |
| When to consider alternatives | Expected count < 5 → Fisher's Exact Test | Non-normal, small n → Mann-Whitney U |
What Is the Chi-Square Test?
In the formula, O is the observed count in each cell, E is the expected count under the null hypothesis, and the summation runs over all cells. Larger departures from expected frequencies produce larger χ² values. The resulting statistic is compared to a chi-square distribution table with the appropriate degrees of freedom to obtain a p-value.
There are two main versions. The Chi-Square Test of Independence asks whether two categorical variables are related — for example, whether voting preference depends on age group. The Chi-Square Goodness-of-Fit Test asks whether one categorical variable follows a specific distribution — for example, whether a die is fair.
Chi-Square Test Assumptions
- Categorical data: Variables must be nominal or ordinal categories, not continuous measurements
- Independent observations: Each participant or unit contributes to exactly one cell in the contingency table
- Expected frequency ≥ 5: All expected cell counts must be at least 5. If not, use Fisher's Exact Test
- Random sampling: Data should come from a random or representative sample
- No paired data: Standard Chi-Square assumes independent groups. For paired categorical data, use McNemar's Test
Oij = observed count in row i, column j
Eij = (row total × column total) / grand total
df = (rows − 1)(columns − 1)
p-value from χ² distribution
What Is the T-Test?
Three distinct T-tests cover most research scenarios. The one-sample T-test compares a sample mean to a known value (for example, testing whether average student performance equals the national benchmark of 70). The independent samples T-test compares means from two unrelated groups (treatment vs. control). The paired samples T-test compares the same group before and after an intervention, or two matched measurements. The formula changes slightly for each type, but the underlying logic — how far is the observed mean from the null hypothesis, measured in units of standard error — remains the same.
William Sealy Gosset, working at Guinness Brewery in Dublin, developed the t-distribution in 1908 while working with small samples of raw materials. He published under the pen name "Student" to protect trade secrets, which is why the test is sometimes called Student's t-test.
T-Test Assumptions
- Continuous outcome: The dependent variable must be measured on an interval or ratio scale
- Normality: The data (or its sampling distribution) should be approximately normal. With n > 30, the Central Limit Theorem makes this assumption robust. Verify with the Shapiro-Wilk test
- Independent observations: Responses from different participants should not influence each other (except in the paired version, where pairs are intentionally linked)
- Homogeneity of variance (independent T-test only): The two groups should have similar variances. Check with Levene's test. If unequal, use Welch's correction
- Random sampling: Data should come from a probability sample
x̄₁, x̄₂ = sample means
sp = pooled standard deviation
n₁, n₂ = sample sizes
df = n₁ + n₂ − 2
The Three T-Test Types Explained
Choosing a T-test also means choosing which version. The data structure — not the research question alone — makes this decision.
| T-Test Type | When to Use | Example |
|---|---|---|
| One-Sample T-Test | Compare a single group mean to a fixed value (population benchmark) | Does average student score differ from the national average of 75? |
| Independent Samples T-Test | Compare means from two separate, unrelated groups | Do men and women differ in average resting heart rate? |
| Paired Samples T-Test | Compare two measurements from the same individuals or matched pairs | Did blood pressure decrease after an 8-week exercise program? |
If your study has more than two groups and a continuous outcome, the T-test is no longer appropriate — switch to ANOVA. See the T-Test vs ANOVA comparison for details.
Decision Tree: Chi-Square vs T-Test (and When to Use Alternatives)
Work through the questions below in order. Each answer points to the next question until you reach a test recommendation.
Statistical Test Selection — Decision Tree
For a broader map of statistical tests beyond these two, visit the statistical test selector on Statistics Fundamentals.
The CHOOSE Framework: A Six-Step Selection Method
The decision tree above answers the core question quickly. The CHOOSE framework provides a more systematic walkthrough — useful in formal research contexts or when reviewing a colleague's analysis for correctness.
CHOOSE: Six Steps to the Right Statistical Test
Worked Examples: Chi-Square vs T-Test in Practice
The following four examples come from different fields. In each case, the first task is identifying which test applies — then running through the full procedure.
Example 1 — Chi-Square Test: Do Treatment Outcomes Differ by Gender?
Problem: A clinical researcher records whether 200 patients responded to a new medication (yes/no) and their gender (male/female). Is there a statistically significant association between gender and treatment response? Use α = 0.05.
Observed frequency table (contingency table):
| Gender | Responded (Yes) | Did Not Respond (No) | Row Total |
|---|---|---|---|
| Male | 55 | 45 | 100 |
| Female | 70 | 30 | 100 |
| Column Total | 125 | 75 | 200 |
Why Chi-Square? Both variables are categorical: gender (male/female) and response (yes/no). The outcome is counts in categories, not a measured number. A T-test is not applicable here.
Hypotheses: H₀: Gender and treatment response are independent. H₁: Gender and treatment response are associated (α = 0.05).
Expected frequencies: E = (row total × column total) / grand total. E(Male, Yes) = (100 × 125)/200 = 62.5. E(Male, No) = 37.5. E(Female, Yes) = 62.5. E(Female, No) = 37.5. All ≥ 5, so Chi-Square is appropriate.
Test statistic:
χ² = [(55−62.5)²/62.5] + [(45−37.5)²/37.5] + [(70−62.5)²/62.5] + [(30−37.5)²/37.5]
χ² = [56.25/62.5] + [56.25/37.5] + [56.25/62.5] + [56.25/37.5]
χ² = 0.90 + 1.50 + 0.90 + 1.50 = 4.80
Degrees of freedom: df = (2 − 1)(2 − 1) = 1. From the chi-square table, the critical value at df = 1, α = 0.05 is 3.841.
Decision: χ² = 4.80 > 3.841 → Reject H₀. Approximate p-value ≈ 0.028. Effect size: φ = √(χ²/n) = √(4.80/200) = 0.155 (small-to-medium association).
✅ Conclusion: There is a statistically significant association between gender and treatment response, χ²(1) = 4.80, p = .028. Female patients responded at a higher rate (70%) than male patients (55%).
Example 2 — Independent Samples T-Test: Do Two Teaching Methods Produce Different Scores?
Problem: An educational researcher compares two teaching methods. Method A (n = 30) produced a mean exam score of 74.2 (s = 9.1). Method B (n = 30) produced a mean score of 81.6 (s = 8.7). Is the difference significant at α = 0.05?
Why T-test? The outcome variable (exam score) is continuous. The research question is about means. Two independent groups are being compared — so an independent samples T-test applies, not Chi-Square.
Hypotheses: H₀: μ₁ = μ₂ (no difference in mean scores) | H₁: μ₁ ≠ μ₂ (two-tailed, α = 0.05). See the null and alternative hypothesis guide.
Assumption check: n = 30 for each group — the Central Limit Theorem supports normality. Levene's test assumed non-significant (p > .05), so we proceed with the equal-variance formula.
Pooled SD and test statistic:
s²p = [(30−1)(9.1²) + (30−1)(8.7²)] / (30 + 30 − 2) = [29(82.81) + 29(75.69)] / 58 = [2401.49 + 2195.01] / 58 = 78.56
sp = √78.56 = 8.86
t = (74.2 − 81.6) / (8.86 · √(1/30 + 1/30)) = −7.4 / (8.86 · 0.258) = −7.4 / 2.286 = −3.24
Critical value: df = 58. From the t-distribution table, t* = ±2.001 at α = 0.05, two-tailed. Our |t| = 3.24 exceeds this.
Decision: |t| = 3.24 > 2.001 → Reject H₀. Approximate p ≈ .002. Effect size: Cohen's d = 7.4 / 8.86 = 0.835 (large effect). See the Cohen's d guide.
✅ Conclusion: Method B produced significantly higher scores than Method A, t(58) = −3.24, p = .002, d = 0.84. The difference of 7.4 points represents a large practical effect.
Example 3 — Spotting the Wrong Test Choice
Which test is appropriate? Evaluate each research question below.
Question: "Is there a relationship between diet type (vegetarian/omnivore) and whether participants developed cardiovascular disease (yes/no) over 10 years?"
Answer: Chi-Square test of independence. Both variables are categorical — diet type and disease outcome are counts, not measurements.
Question: "Do vegetarians have a lower average BMI than omnivores?"
Answer: Independent samples T-test. BMI is a continuous measurement, and we are comparing two group means.
Question: "Did participants' blood pressure decrease after completing a mindfulness program?" (Same 40 participants measured before and after.)
Answer: Paired samples T-test. Blood pressure is continuous, and the same individuals are measured twice — creating paired (not independent) data.
Question: "Does the distribution of political party affiliation in a local sample match the national distribution?"
Answer: Chi-Square goodness-of-fit test. We are comparing an observed categorical frequency distribution to an expected theoretical one — not comparing means.
Example 4 — Chi-Square vs T-Test in A/B Testing
Case Study: E-Commerce A/B Test
When do you use Chi-Square vs T-test for website testing?
An e-commerce company runs two versions of a product page. Version A is seen by 1,200 visitors; Version B by 1,200 visitors. Two outcomes are tracked: (1) whether each visitor made a purchase (yes/no) and (2) the average order value in dollars for those who purchased.
For conversion rate (did they buy or not?): This is categorical. Use a Chi-Square test of independence to determine whether Version B had a significantly different conversion rate. The contingency table has two rows (version A vs B) and two columns (purchased vs not purchased).
For average order value (dollars spent): This is continuous. Use an independent samples T-test to determine whether the mean order value differed between the two page versions.
The same A/B test can legitimately require both tests, applied to different outcomes. See the detailed discussion in how statistics powers A/B testing.
Extended Comparison: Chi-Square and T-Test Alternatives
Knowing when not to use these two tests is as important as knowing when to use them.
| Scenario | Chi-Square Alternative | T-Test Alternative |
|---|---|---|
| Expected cell frequency < 5 | Fisher's Exact Test | N/A |
| Paired categorical data (before/after) | McNemar's Test | Paired Samples T-Test |
| Non-normal data, two independent groups | Chi-Square (already nonparametric) | Mann-Whitney U Test |
| Non-normal data, paired groups | McNemar's Test | Wilcoxon Signed-Rank Test |
| Three or more groups, continuous outcome | Chi-Square (categorical) | One-Way ANOVA |
| Ordinal outcome variable | Chi-Square (if treating as categories) | Mann-Whitney U or Wilcoxon (safer) |
Understanding the full family of parametric and nonparametric tests is covered in the hypothesis testing hub on Statistics Fundamentals.
Running Chi-Square and T-Tests in R, Python, and SPSS
Below is the syntax for both tests across the three most widely used statistical software packages.
R Syntax
table_data <- table(df$gender, df$response)
result <- chisq.test(table_data)
print(result) # Returns χ², df, p-value
# Goodness-of-Fit
chisq.test(x = observed_counts, p = expected_proportions)
t.test(df$score, mu = 70)
# Independent samples T-test
t.test(score ~ group, data = df, var.equal = TRUE)
# Paired T-test
t.test(df$before, df$after, paired = TRUE)
Python Syntax (SciPy)
import numpy as np
# Chi-Square Test of Independence
chi2, p, dof, expected = stats.chi2_contingency(contingency_table)
# Independent samples T-test
t_stat, p_val = stats.ttest_ind(group1, group2)
# Paired T-test
t_stat, p_val = stats.ttest_rel(before, after)
# One-sample T-test
t_stat, p_val = stats.ttest_1samp(data, popmean=70)
SPSS Steps
Chi-Square in SPSS
Analyze → Descriptive Statistics → Crosstabs. Move your two categorical variables to Row(s) and Column(s). Click Statistics → Check "Chi-square." Click Cells → Check "Expected" to verify assumption. Output reports Pearson Chi-Square, df, and asymptotic significance (p-value).
Independent Samples T-Test in SPSS
Analyze → Compare Means → Independent-Samples T Test. Move the continuous variable to "Test Variable(s)" and the grouping variable to "Grouping Variable." Define the two group values. The output includes Levene's test (for equal variances) and both equal-variance and Welch-corrected t-test results.
Paired T-Test in SPSS
Analyze → Compare Means → Paired-Samples T Test. Select both the pre-measurement and post-measurement variables and move them as a pair. Output includes mean difference, standard deviation of difference, t statistic, df, and p-value.
Real-World Applications by Field
Healthcare
Chi-Square: Is the proportion of patients who recover different between drug A and drug B? T-Test: Does drug A reduce systolic blood pressure more than drug B?
Education
Chi-Square: Is pass/fail rate different between schools in two districts? T-Test: Do students who receive tutoring score higher on average?
Marketing
Chi-Square: Does email click-through rate differ by customer segment? T-Test: Does average cart value differ between customers who saw ad A vs ad B?
Psychology
Chi-Square: Is anxiety diagnosis more common in one demographic group? T-Test: Does a 6-week therapy program reduce average depression scores?
Manufacturing
Chi-Square: Is the defect rate different across three production lines? T-Test: Does Machine B produce parts with smaller average measurement error?
Social Science
Chi-Square: Is voting preference associated with education level? T-Test: Do urban and rural residents differ in average weekly hours worked?
Common Mistakes When Choosing Between These Tests
| Mistake | What Goes Wrong | Correct Approach |
|---|---|---|
| Using a T-test for binary outcomes (0/1 coded) | Treating yes=1, no=0 as continuous and computing a mean — the "mean" of a binary variable has no intuitive meaning | Use Chi-Square for categorical outcomes. Use logistic regression if you need to control for covariates. |
| Using Chi-Square when expected counts are below 5 | The χ² approximation breaks down; p-values become unreliable, usually anti-conservative | Switch to Fisher's Exact Test, which gives exact p-values for small samples |
| Applying an independent T-test to paired data | Ignoring the correlation between paired measurements reduces statistical power substantially | Use a paired T-test (or Wilcoxon signed-rank test if normality fails) |
| Using T-test for three or more groups | Running multiple T-tests inflates the Type I error rate (multiple comparisons problem) | Use one-way ANOVA, then a post-hoc test (Tukey's HSD) for pairwise comparisons |
| Confusing statistical significance with practical importance | A p-value alone tells you nothing about the size of an effect — only whether it is detectable | Always report an effect size: Cohen's d for T-tests, Cramér's V or φ for Chi-Square |
| Ignoring the normality assumption for small samples | The T-test with n < 30 and strongly skewed data yields inaccurate p-values | Check normality with Shapiro-Wilk; if violated, use the Mann-Whitney U test |
Interactive Test Selector
Answer two questions below to get an immediate test recommendation for your data.
Chi-Square vs T-Test Selector
Practice Problems: Choose the Correct Test
For each scenario, decide whether a Chi-Square test or T-test is appropriate — and which specific variant. Reveal the answer after you have made your choice.
Scenario: A survey of 500 adults asks whether they voted in the last election (yes/no) and their age group (18–34, 35–54, 55+). The researcher wants to know whether voting participation differs across age groups.
Which test is appropriate and why?
Scenario: A pharmaceutical company tests whether a new sleep aid reduces average nightly sleep latency (minutes to fall asleep). Forty participants are measured before and after 4 weeks of treatment.
Which test is appropriate and why?
Scenario: A quality control team inspects 300 items from three production lines and records whether each item passes or fails inspection. They want to know whether defect rates differ across lines.
Which test is appropriate and why?
Scenario: A social scientist wants to know whether average annual household income is higher in urban areas than rural areas. Data is collected from 45 urban and 42 rural households.
Which test is appropriate and why?
Glossary of Key Terms
Frequently Asked Questions
Summary: Chi-Square Test vs T-Test at a Glance
The choice between a Chi-Square test and a T-test comes down to one question about your data: are your observations counts in categories, or measured numbers? That single distinction separates these two tests more clearly than any other consideration. Assumptions, formulas, and software functions follow from there.
When your outcome is categorical and you want to know whether two variables are related, the Chi-Square test of independence is the right choice. When your outcome is continuous and you want to compare means between one or two groups, the T-test is appropriate. When either test's assumptions are violated, Fisher's Exact Test (for small expected cell counts) and the Mann-Whitney U test (for non-normal continuous data) are the standard alternatives.
Statistical decisions do not exist in isolation. For a complete reference on all common hypothesis tests, visit the hypothesis testing section and the statistical test selector on Statistics Fundamentals.