Chi square test

Searching the Web

chi square test types formula applications statistics

Here is a thorough breakdown of the chi-square (χ²) test:

Chi-Square Test (χ²)

What It Is

The chi-square test is a non-parametric statistical test used exclusively with categorical data. It measures how much observed frequencies differ from expected frequencies under the null hypothesis. Because it makes no assumptions about the underlying population distribution, it is one of the most widely used tests in statistics, research, and science.

The Core Formula

χ² = Σ [ (O - E)² / E ]
SymbolMeaning
χ²Chi-square test statistic
OObserved frequency (actual data counts)
EExpected frequency (what you'd expect under H₀)
ΣSum over all categories/cells
How it works:
  1. Subtract expected from observed for each category: (O - E)
  2. Square the difference: (O - E)²
  3. Divide by expected count to normalize: (O - E)² / E
  4. Sum all values to get χ²
A larger χ² value means observed data deviate more from expectations.

Two Main Types

1. Chi-Square Goodness of Fit Test

  • Purpose: Tests whether a single categorical variable follows an expected distribution.
  • Question: "Does my observed data match a theoretical or expected distribution?"
  • Example: You roll a die 60 times. Do all 6 faces come up equally (~10 times each)? You compare observed rolls to the expected 10 per face.
  • Degrees of freedom: k - 1 (where k = number of categories)

2. Chi-Square Test of Independence

  • Purpose: Tests whether two categorical variables are associated or independent.
  • Question: "Is variable A related to variable B?"
  • Example: Is smoking status (smoker/non-smoker) related to lung disease (yes/no)? Uses a contingency table.
  • Degrees of freedom: (rows - 1) × (columns - 1)

Step-by-Step Procedure

  1. State hypotheses:
    • H₀: No difference from expected / Variables are independent
    • H₁: Significant difference / Variables are associated
  2. Choose significance level (α), typically 0.05
  3. Calculate expected frequencies:
    • Goodness of fit: based on theoretical proportions
    • Independence: E = (Row total × Column total) / Grand total
  4. Compute χ² statistic using the formula above
  5. Find degrees of freedom (df)
  6. Get the p-value from a chi-square distribution table or software
  7. Decision:
    • If p < α → Reject H₀ (significant result)
    • If p ≥ α → Fail to reject H₀

Assumptions & Conditions

ConditionRequirement
Data typeCategorical (nominal or ordinal)
IndependenceObservations must be independent
Sample sizeEach expected cell frequency ≥ 5
SamplingRandom sampling
If expected cell counts are < 5, use Fisher's Exact Test instead (especially for 2×2 tables with small samples).

Worked Example: Test of Independence

Scenario: Is there a relationship between gender (Male/Female) and preference for tea/coffee?
TeaCoffeeTotal
Male302050
Female153550
Total4555100
Expected values (e.g., Male-Tea): (50 × 45) / 100 = 22.5
χ² = (30-22.5)²/22.5 + (20-27.5)²/27.5 + (15-22.5)²/22.5 + (35-27.5)²/27.5 = 2.5 + 2.045 + 2.5 + 2.045 = ~9.09
df = (2-1)(2-1) = 1
At df=1, χ² = 9.09 → p ≈ 0.003 → Reject H₀. Gender and beverage preference are significantly associated.

Effect Size: Cramer's V

A significant χ² only tells you there's an association, not how strong it is. Use Cramer's V for effect size:
V = √(χ² / (n × min(r-1, c-1)))
VInterpretation
0.1Weak
0.3Moderate
0.5+Strong

When to Use Chi-Square vs. Alternatives

SituationTest to Use
Categorical data, large sampleChi-square
2×2 table with small nFisher's Exact Test
Paired/matched categorical dataMcNemar's Test
Ordinal data with ordered categoriesCochran-Armitage trend test
Continuous data, two groupst-test or Mann-Whitney U

Common Applications

  • Medicine/Epidemiology: Comparing disease rates between treatment and control groups
  • Market research: Preference surveys across demographic groups
  • Genetics: Testing Mendelian inheritance ratios
  • Social sciences: Survey response analysis by group
  • Quality control: Checking whether defects follow an expected pattern

Test of significance

Searching the Web

test of significance statistics types steps examples

Here is a complete guide to Tests of Significance:

Tests of Significance

Definition

A test of significance is a statistical method used to determine whether the difference between observed sample results and what is expected under the null hypothesis is large enough to be attributed to something other than chance. It helps researchers decide if their findings are statistically meaningful or merely due to random variation.

Key Concepts

1. Null Hypothesis (H₀)

  • The default assumption - states there is no effect, no difference, or no relationship.
  • Example: "There is no difference in mean blood pressure between the drug group and placebo group."

2. Alternative Hypothesis (H₁ or Hₐ)

  • What you want to prove - states there is an effect or difference.
  • Can be one-tailed (directional) or two-tailed (non-directional).

3. Level of Significance (α)

  • The threshold probability for rejecting H₀.
  • Common values:
αConfidence LevelUse
0.0595%Most common in research
0.0199%Stricter standard
0.1090%Exploratory studies

4. p-value

  • The probability of obtaining results as extreme as or more extreme than observed, assuming H₀ is true.
  • If p ≤ α → Result is statistically significant → Reject H₀
  • If p > α → Result is not significant → Fail to reject H₀

5. Test Statistic

  • A calculated value from sample data (e.g., z, t, F, χ²) used to determine the p-value.
  • Each test has its own formula and sampling distribution.

6. Critical Value

  • The boundary value from the relevant statistical table beyond which H₀ is rejected.
  • If test statistic > critical value → Reject H₀

General Steps in a Test of Significance

Step 1: State H₀ and H₁
Step 2: Choose significance level (α)
Step 3: Select the appropriate test
Step 4: Check assumptions
Step 5: Compute the test statistic
Step 6: Find p-value or compare to critical value
Step 7: Make a decision (Reject or Fail to Reject H₀)
Step 8: State conclusion in context

Types of Tests of Significance

Tests are classified based on data type, number of groups, and distribution assumptions.

A. Parametric Tests

(Assume data follows a normal distribution; used for continuous data)
TestUse CaseFormula/Statistic
z-testLarge samples (n ≥ 30), known population σz = (x̄ - μ) / (σ/√n)
One-sample t-testSmall sample, unknown σ, test mean vs. known valuet = (x̄ - μ) / (s/√n)
Independent t-testCompare means of two independent groupst = (x̄₁ - x̄₂) / SE
Paired t-testCompare means of same group at two time pointst = d̄ / (s_d/√n)
One-way ANOVACompare means of 3+ independent groupsF = Variance between / Variance within
Two-way ANOVATwo factors simultaneouslyF-statistic
Pearson's correlationLinear relationship between two continuous variablesr statistic

B. Non-Parametric Tests

(No distribution assumption; used for ordinal, nominal, or non-normal data)
TestParametric EquivalentUse Case
Chi-square (χ²)-Categorical data (frequencies)
Mann-Whitney UIndependent t-testTwo independent non-normal groups
Wilcoxon signed-rankPaired t-testPaired non-normal data
Kruskal-WallisOne-way ANOVA3+ independent non-normal groups
Spearman's rankPearson correlationOrdinal or non-normal continuous data
Fisher's ExactChi-squareSmall sample 2×2 tables

Types of Errors

H₀ is TrueH₀ is False
Reject H₀Type I Error (α)Correct (Power = 1-β)
Fail to Reject H₀Correct (1-α)Type II Error (β)
  • Type I Error (False Positive): Rejecting a true H₀. Controlled by α.
  • Type II Error (False Negative): Failing to reject a false H₀. Controlled by β.
  • Power (1-β): Probability of correctly detecting a true effect. Ideally ≥ 0.80.

One-Tailed vs. Two-Tailed Tests

FeatureOne-TailedTwo-Tailed
Hypothesis directionSpecific (greater or less than)Non-directional (not equal)
Critical regionOne side of distributionBoth sides
More sensitiveYes (for specific direction)No
Use whenPrior evidence suggests directionNo prior expectation

Choosing the Right Test

Is your outcome variable continuous or categorical?
│
├── Continuous
│   ├── Is data normally distributed?
│   │   ├── Yes (Parametric)
│   │   │   ├── 1 group vs. known value → One-sample t-test / z-test
│   │   │   ├── 2 independent groups → Independent t-test
│   │   │   ├── 2 paired groups → Paired t-test
│   │   │   └── 3+ groups → ANOVA
│   │   └── No (Non-parametric)
│   │       ├── 2 independent groups → Mann-Whitney U
│   │       ├── 2 paired groups → Wilcoxon signed-rank
│   │       └── 3+ groups → Kruskal-Wallis
│
└── Categorical
    ├── Large sample → Chi-square test
    └── Small sample (2×2) → Fisher's Exact Test

Worked Example: z-test

Problem: A sample of 50 students has a mean score of 78. The population mean is known to be 75, with σ = 10. Is this difference significant at α = 0.05?
Step 1: H₀: μ = 75 | H₁: μ ≠ 75 (two-tailed)
Step 2: α = 0.05 → Critical z = ±1.96
Step 3:
z = (x̄ - μ) / (σ/√n) = (78 - 75) / (10/√50) = 3 / 1.414 = 2.12
Step 4: |2.12| > 1.96 → Reject H₀
Conclusion: The sample mean is significantly different from the population mean at the 5% level (z = 2.12, p < 0.05).

Statistical Significance vs. Practical Significance

A result can be statistically significant yet practically meaningless, especially with large samples. Always pair significance tests with:
  • Effect size (Cohen's d, r, η², Cramer's V)
  • Confidence intervals
  • Clinical/practical context
Example: A drug lowers blood pressure by 1 mmHg with p = 0.001. Statistically significant - but clinically irrelevant.

Summary Table

ConceptMeaning
H₀Null hypothesis (no effect)
H₁Alternative hypothesis (effect exists)
αSignificance level (typically 0.05)
p-valueProbability of result under H₀
Test statisticz, t, F, χ² - computed from data
Type I ErrorFalsely rejecting H₀
Type II ErrorFailing to detect a real effect
PowerAbility to detect a true effect
This is a shared conversation. Sign in to Orris to start your own chat.