🎲 Module 1: Why Chi-Square Matters

Understanding Categorical Data Analysis

📚 Learning Objectives

By the end of this module, you will be able to:

🔍 Understanding Variable Types: The Foundation

Before we can understand Chi-square, we need to be crystal clear about what kind of data we're working with.

Categorical Variables (Also Called: Nominal, Discrete, Qualitative)

Categorical variables represent groups, categories, or classifications. They answer "what kind?" or "which category?"

Examples:

Continuous Variables (Also Called: Quantitative, Measurement)

Continuous variables represent measurements or counts. They answer "how much?" or "how many?"

Examples:

💡 Key Insight: Why This Matters

Different variable types require different statistical tests!

Chi-square is specifically designed for categorical data. If you try to use it on continuous data, you're using the wrong tool!

🎯 Interactive Activity: Categorize These Variables

Drag each variable into the correct category. This skill is essential for choosing the right statistical test!

Variable Bank (Drag these):

Neuron type (pyramidal, interneuron)
Firing rate (spikes/second)
Handedness (left, right)
Age (years)
Treatment outcome (improved, no change, worse)
Anxiety score (0-50 scale)
Maze arm chosen (left, right, center)
Time to find platform (seconds)

📊 Categorical Variables

Drop categorical variables here

📈 Continuous Variables

Drop continuous variables here

🎲 What Does Chi-Square Test?

Chi-square tests answer questions about frequencies and proportions in categorical data.

The core question Chi-square asks:

"Are the observed frequencies different from what we'd expect?"

Two Types of Chi-Square Tests:

1️⃣ Goodness-of-Fit Test

One categorical variable

Tests if observed distribution matches an expected distribution

Example questions:

  • Do rats choose maze arms equally?
  • Are births evenly distributed across weekdays?
  • Does a die land fairly on all sides?

2️⃣ Test of Independence

Two categorical variables

Tests if two variables are related or independent

Example questions:

  • Is treatment response related to sex?
  • Does species affect habitat preference?
  • Is diagnosis associated with treatment type?

📊 Visual Demo: Expected vs. Observed Frequencies

Let's see how Chi-square works with a simple example:

Research Question: Do rats have a left/right preference?

We test 60 rats in a T-maze where they must choose left or right. If there's no preference (null hypothesis), we'd expect 30 to go left and 30 to go right.

Expected (No Preference)

Direction Expected Count
Left 30
Right 30

Observed (Actual Data)

Direction Observed Count
Left 42
Right 18

The Chi-square test calculates: How different is the observed pattern from what we expected?

Interpretation: The observed frequencies (42 left, 18 right) are quite different from expected (30, 30). Chi-square will tell us if this difference is statistically significant or just random variation.

✅ When Should You Use Chi-Square?

Use Chi-square when ALL of these are true:

DO NOT use Chi-square when:

🎯 Interactive Activity: Choose the Right Test

For each research question below, decide if Chi-square is appropriate or if you should use a different test.

🤔 Check Your Understanding

Question 1: A researcher measures reaction time (in milliseconds) for participants who drank coffee vs. no coffee. Should they use Chi-square?

A) Yes, because there are two groups (coffee vs. no coffee)
B) No, because reaction time is continuous, not categorical
C) Yes, because we're comparing groups

Question 2: A researcher categorizes 100 patients as "improved," "no change," or "worse" after treatment. They want to test if the distribution differs from equal proportions (33%, 33%, 33%). Which Chi-square test should they use?

A) Goodness-of-fit test (one categorical variable)
B) Test of independence (two categorical variables)
C) Neither - should use ANOVA

Question 3: You want to know if males and females differ in their choice of three different habitats (forest, grassland, desert). Which test?

A) Goodness-of-fit test
B) Test of independence (Chi-square for two categorical variables)
C) Two-way ANOVA

📝 Module 1 Summary

Key Takeaways:

Next up: Module 2 will teach you how to run Chi-square goodness-of-fit tests in R and interpret the results!