1 of 31

Lecture – Chi Square Goodness of Fit Test

PSYC 3510

Matthew Babb

2 of 31

Review and Reminders

Reminders

  • Workshop due this Friday (5/26)
  • Reading Quiz due next Monday (5/29)

Review

  • Null Hypothesis
  • Test of Significance
  • p-value and what it means

3 of 31

Chi Square Test

4 of 31

Goals for Today

  • Chi-Square Test
    • What it is, when to use it, and how to use it
  • How to calculate Chi-Square Value
  • Solve a Chi-Square Example

5 of 31

Chi Square Test

  • Test of Association between Categorical Variables
  • Compares Actual Data to Expected Data
  • Only works with Categorical Data

(Observed Data – Expected Data)

Expected

=

2

Σ

6 of 31

Types of Chi Square Tests

  1. 𝝌2 Goodness of Fit Test
    • Examines one variable
    • Compares actual frequencies to the expected frequencies
    • Compares sample of data to population of data

2. 𝝌2 Test of Independence

    • Examines two variables
    • Determines if membership in one category is independent of membership in another category
    • Compares frequencies of variable 1 to two categories of variable 2

7 of 31

Types of Chi Square Tests

  1. 𝝌2 Goodness of Fit Test
    • EX: “Does the sex distribution in Congress reflect the sex distribution of the entire United States?“
    • EX: “Do the five flavors of skittles occur evenly throughout every bag?”

2. 𝝌2 Test of Independence

    • EX: “Is the sex distribution in Congress the same between Democrats and Republicans?”
    • EX: “Does peanut butter preference (creamy or crunchy) determine if drive slow in the fast lane?”

8 of 31

9 of 31

10 of 31

11 of 31

Chi Square Example

  • Question: Does the gender distribution of those affected with COVID-2.0 reflect the gender distribution of the entire United States?
  • Variable: Gender

12 of 31

Null Hypothesis and Significance Testing

  1. State the hypotheses
  2. Set the criteria for a decision
  3. Collect the data & compute test statistic

- In this case it’s a Chi Square Value

  • Decide to reject or accept the null

13 of 31

1. State Hypotheses

  • Question: Does the gender distribution of those affected with COVID-2.0 reflect the gender distribution of the entire United States?

  • Null Hypothesis
    • There is no difference between the gender distribution of those infected by COVID-2.0 and the US Population

  • Alternative Hypothesis
    • There is a difference between the gender distribution of those infected by COVID-2.0 and the US Population

14 of 31

2. Set Criteria for Decision

P-value

  • To set criteria, we need to use the Chi Square Distribution
  • Which line?
  • Depends upon number of categories in your variable of interest
  • Degrees of Freedom (df)
  • df = k – 1 (where k is the number of categories)

15 of 31

Chi Square Distribution

P-value

1 2 3

Male

Female

*

df = k – 1

(k is the number of categories)

16 of 31

How many degrees of freedom?

17 of 31

Chi Square Distribution

P-value

1 2 3

Male

Female

*

df = k – 1

(k is the number of categories)

18 of 31

2. Set Criteria for Decision

df = 2

P-value

19 of 31

2. Set Criteria for Decision

P-value

  • α = 0.05
  • When α = 0.05, the χ2 value is 5.99
  • That is our criteria.
  • If we get a χ2 value above 5.99, then we can reject our null hypothesis

α = 0.05

5.99

I will always give you this number! But I do want you to know how to find it

20 of 31

3. Compute our Statistic

  • 3 Groups in our Category
  • Formula:

(Obs. Freq. – Exp. Freq.)2

Exp. Freq.

=

Male

Female

*

(Obs. Freq. – Exp. Freq.)2

Exp. Freq.

+

+

(Obs. Freq. – Exp. Freq.)2

Exp. Freq.

21 of 31

3. Compute our Statistic

Male

Female

*

Total

Observed Frequency

407

127

0

534

22 of 31

3. Compute our Statistic

  • 3 Groups in our Category
  • Formula:

=

Male

Female

*

(407 – Exp. Freq.)2

Exp. Freq.

(127 – Exp. Freq.)2

Exp. Freq.

+

+

(0 Exp. Freq.)2

Exp. Freq.

23 of 31

3. Compute our Statistic

Male

Female

*

Total

US Population

0.44

0.46

0.10

1.00

Expected Frequency

0.44 x 534 =

234.96

0.46 x 534 =

245.64

0.10 x 534 =

53.40

534

24 of 31

3. Compute our Statistic

  • 3 Groups in our Category
  • Formula:

(407 – 234.96)2

234.96

=

Male

Female

*

(127 – 245.64)2

245.64

+

+

(0 – 53.40)2

53.40

25 of 31

3. Compute our Statistic

  • 3 Groups in our Category
  • Formula:

(407234.96)2

234.96

=

Male

Female

*

(127245.64)2

245.64

+

+

(053.40)2

53.40

57.30

53.40

125.97

=

236.67

26 of 31

3. Compute our Statistic

=

236.67

27 of 31

4. Decide to accept or reject the null

P-value

α = 0.05

=

236.67

Criteria = 5.99

5.99

If > criteria, we reject the null

If < criteria, we fail to reject the null

28 of 31

Do we reject or fail to reject the null?

=

236.67

Criteria = 5.99

29 of 31

Results

  • “The gender distribution of those affected by COVID 2.0 is significantly different from the gender distribution in the US population, (2, N = 534) = 236.67, p < 0.05”

30 of 31

Key Concepts

  • What a goodness of fit is used for
  • Formula for
  • Chi-Square Distribution
  • How to calculate Expected frequencies
  • Compare Chi Square value to criteria
  • Decide to reject or accept null hypothesis

(Obs– Exp)

Exp

=

2

Σ

P-value

Cat.1

Cat.2

Expected

234.96

245.64

Observed

407

127

31 of 31

If we have 2 categories, what is the criteria if α = 0.2?