Hypothesis testing Z-Scores
What is a Z-Score?
- A z-score tells us how many standard deviations a value is from the mean.
- Positive z-scores are above the mean
- Negative z-scores are below the mean
- A z-score is the precise representation of the 68-95-99 Rule
The 68-95-99.7 Rule
![]()
68-95-99.7 rule
What is a Z-Score? (cont)
- The actual 95% area under the normal curve is between -1.96 and +1.96 standard deviations from the mean
- The actual 95% area is from z = -1.96 to z = 1.956
- If the area under the curve is 95%, then 5% is outside it in the two tails
The tails
Two-tail test
- In a hypothesis test, we are testing the probability that the event is not due to random chance
- We set a threshold (usually α = 0.05) for how unlikely a result must be before we reject the null hypothesis
- In a two-tail test, we split α into both tails: α/2 = 0.025 in each tail
- If our test statistic falls in either tail (beyond ±1.96), we reject the null hypothesis
- This corresponds to a probability less than 5% or p < .05
Z-Test: Steps
Steps:
- State your null hypothesis (\(H_0: \mu = \mu_0\)) and alternative hypothesis (\(H_a\))
- Calculate the test statistic using the formula above
- For a two-tail test at \(\alpha = 0.05\), the critical values are \(z = \pm 1.96\)
Z-test: Decision rule
Two tail:
- Reject \(H_0\) if \(z > 1.96\) or \(z < -1.96\)
- Fail to reject \(H_0\) if \(-1.96 \le z \le 1.96\)
- Shorthand: reject if \(|z| > 1.96\)
Z-tail: Right tail decision rule
Right-tail test (\(H_a: \mu > \mu_0\))
- Critical value: \(z_{critical} = 1.645\)
- Decision rule:
- Reject \(H_0\) if \(z > 1.645\)
- Fail to reject \(H_0\) if \(z \le 1.645\)
- Shorthand: reject if \(z\) is in the right tail beyond 1.645
Z-tail: Left-tail decision rule
Left-tail test (\(H_a: \mu < \mu_0\))
- Critical value: \(z_{critical} = -1.645\)
- Decision rule:
- Reject \(H_0\) if \(z < -1.645\)
- Fail to reject \(H_0\) if \(z \ge -1.645\)
- Shorthand: reject if \(z\) is in the left tail beyond -1.645
What is a Crosstab?
- A crosstab (contingency table) shows counts for two categorical variables in rows and columns
- Each cell contains the frequency of cases with that combination of categories
Example Crosstab
Example structure (2×3 table):
| Group A |
? |
? |
? |
| Group B |
? |
? |
? |
Example: Observed Counts Only
Research Question: Is there an association between gender and support for a new campus policy?
Observed data from 200 students:
Example: Add Row and Column Totals
Fill in the marginals (row totals, column totals, and grand total):
| Female |
60 |
40 |
___ |
| Male |
45 |
55 |
___ |
| Column Total |
___ |
___ |
**___** |
Example: Completed Observed Table
| Female |
60 |
40 |
100 |
| Male |
45 |
55 |
100 |
| Column Total |
105 |
95 |
200 |
Example: Calculate Expected Counts
Formula: \(E_{ij} = \frac{(\text{row total}) \times (\text{column total})}{\text{grand total}}\)
Calculate expected count for each cell:
- Female & Support: \(E_{11} = \frac{100 \times 105}{200} = \_\_\_\)
- Female & Oppose: \(E_{12} = \frac{100 \times 95}{200} = \_\_\_\)
- Male & Support: \(E_{21} = \frac{100 \times 105}{200} = \_\_\_\)
- Male & Oppose: \(E_{22} = \frac{100 \times 95}{200} = \_\_\_\)
Example: Expected Counts Table
| Female |
52.5 |
47.5 |
100 |
| Male |
52.5 |
47.5 |
100 |
| Column Total |
105 |
95 |
200 |
These are the counts we would expect if there were NO association
Example: Calculate (O - E) for Each Cell
For each cell, compute: Observed - Expected
| Female |
60 - 52.5 = ___ |
40 - 47.5 = ___ |
| Male |
45 - 52.5 = ___ |
55 - 47.5 = ___ |
Example: Differences (O - E)
| Female |
+7.5 |
-7.5 |
| Male |
-7.5 |
+7.5 |
Note the symmetry: Differences sum to zero in each row and column
Where did we run into this before?
- Variance
- When we talked about computing confidence intervals, squaring deviations meant we couldn’t use the normal distribution
- That meant we couldn’t use a z-score there
- What distribution did we have to use?
Distribution Comparison
χ² instead of z-score
- Here we will use the χ² statistic instead of the z-score
- The z-score is always based on the same normal distribution
- The chi-square is not just one curve: we pick a specific χ² distribution based on the degrees of freedom
What is degrees of freedom?
- Chi-square shows up whenever we add up squared differences between what we observe and what we expect
- These are also called squared residuals
- The degrees of freedom tell us how many independent pieces of information went into that total
- In a crosstab, fixing the row and column totals means not every cell can vary freely, so the df is \((r - 1)(c - 1)\)
- So instead of one universal z table, we have a family of χ² tables—one curve for each degrees-of-freedom value.
χ² Critical Values (α = 0.05)
| 1 |
3.84 |
| 2 |
5.99 |
| 3 |
7.82 |
| 4 |
9.49 |
| 5 |
11.07 |
| 6 |
12.59 |
Example: next step
Calculate \(\frac{(O - E)^2}{E}\) for Each Cell
\[\chi^2 = \sum \frac{(O - E)^2}{E}\]
Female & Support: \(\frac{(7.5)^2}{52.5} = \frac{56.25}{52.5} = \_\_\_\)
Female & Oppose: \(\frac{(-7.5)^2}{47.5} = \frac{56.25}{47.5} = \_\_\_\)
Male & Support: \(\frac{(-7.5)^2}{52.5} = \frac{56.25}{52.5} = \_\_\_\)
Male & Oppose: \(\frac{(7.5)^2}{47.5} = \frac{56.25}{47.5} = \_\_\_\)
Example: Chi-Square Components
Female & Support: \(\frac{56.25}{52.5} = 1.071\)
Female & Oppose: \(\frac{56.25}{47.5} = 1.184\)
Male & Support: \(\frac{56.25}{52.5} = 1.071\)
Male & Oppose: \(\frac{56.25}{47.5} = 1.184\)
Sum all four: \(\chi^2 = 1.071 + 1.184 + 1.071 + 1.184 = \_\_\_\)
Example: Chi-Square Test Statistic
\[\chi^2_{calc} = 4.51\]
Now we need to compare this to the critical value
Example: Find Degrees of Freedom
\[df = (r - 1)(c - 1)\]
- Number of rows: \(r = \_\_\_\)
- Number of columns: \(c = \_\_\_\)
\[df = (\_\_\_ - 1)(\_\_\_ - 1) = \_\_\_\]
Example: Degrees of Freedom
\[df = (r - 1)(c - 1)\]
- Number of rows: \(r = 2\)
- Number of columns: \(c = 2\)
\[df = (2 - 1)(2 - 1) = 1\]
Example: Critical Value
From chi-square distribution table:
- \(df = 1\)
- \(\alpha = 0.05\)
- \(\chi^2_{critical} = 3.841\)
Example: Make Decision
Decision rule: Reject \(H_0\) if \(\chi^2_{calc} > \chi^2_{critical}\)
Our values: - \(\chi^2_{calc} = 4.51\) - \(\chi^2_{critical} = 3.841\)
Decision: _______________
Example: Conclusion
Since \(4.51 > 3.841\), we REJECT \(H_0\)
Conclusion: - There is a statistically significant association between gender and support for the policy - The pattern in our sample is unlikely to be due to chance alone - Females show higher support (60%) than males (45%)
Berkeley Graduate Admissions 1973
Did America’s most progressive graduate school discriminate on gender in admissions?
, , Dept = A
Gender
Admit Male Female
Admitted 512 89
Rejected 313 19
, , Dept = B
Gender
Admit Male Female
Admitted 353 17
Rejected 207 8
, , Dept = C
Gender
Admit Male Female
Admitted 120 202
Rejected 205 391
, , Dept = D
Gender
Admit Male Female
Admitted 138 131
Rejected 279 244
, , Dept = E
Gender
Admit Male Female
Admitted 53 94
Rejected 138 299
, , Dept = F
Gender
Admit Male Female
Admitted 22 24
Rejected 351 317
Dept A B C D E F
Admit Gender
Admitted Male 512 353 120 138 53 22
Female 89 17 202 131 94 24
Rejected Male 313 207 205 279 138 351
Female 19 8 391 244 299 317
1973 Berkeley Example Data (Overall)
Overall admissions (all departments combined)
| Male |
44 |
56 |
100 |
| Female |
30 |
70 |
100 |
| Total |
74 |
126 |
200 |
1973 Berkeley Example Data (By Department)
Admissions by department (simplified)
| A |
Male |
40 |
60 |
100 |
|
Female |
45 |
55 |
100 |
| B |
Male |
30 |
70 |
100 |
|
Female |
36 |
64 |
100 |
| C |
Male |
30 |
70 |
100 |
|
Female |
15 |
85 |
100 |
For this week’s quiz points (25 points)
Complete the crosstabs hypothesis test for the table with admissions by department. (That is a single test with 6 rows by 2 columns)
Do a crosstab for each department. (That is 3 tests with 2 rows by 2 rows)
Do this by hand and give your conclusions.
More on the next slide
Part 2
Bring this to class Thursday or turn it in my mailbox in the Political Science Department office (PGH 447)
Mostly completion - if you make errors, we will discuss
Read these and answer three questions in Canvas “March 23-26 Quiz”
- https://setosa.io/simpsons/
- https://statisticsbyjim.com/basics/simpsons-paradox/
We will revisit using R in lab on Thursday!
I will post Thursday lab Monday or Tuesday evening with recording
Authorship, License, Credits
![Creative Commons License]()