STAT1003 – Statistical Techniques
Dr. Emi Tanaka
Australian National University
These slides are best viewed on a modern browser like Google Chrome on a desktop or laptop. Some interactive components may require some time to fully load.
This lecture was partially adapted from the previous STAT1003 lecturers. Thank you folks!

The chi-squared test statistic is defined as:
\[X^2 = \sum_{i=1}^k \frac{(O_i - E_i)^2}{E_i} = \sum_{i=1}^k \frac{O_i^2}{E_i} - n.\]
P-value is calculated as: \(P(\chi^2_{k-1} > X^2)\).
| Category | A | B | AB | O |
|---|---|---|---|---|
| \(O_i\) | 85 | 40 | 15 | 60 |
| \(E_i\) | 80 | 50 | 20 | 50 |
The scripted buyers asked one of three questions:
| General | Positive | Negative | Total | |
|---|---|---|---|---|
| Disclose Problem | 2 | 23 | 36 | 61 |
| Hide Problem | 71 | 50 | 37 | 158 |
| Total | 73 | 73 | 73 | 219 |
| General | Positive | Negative | Total | |
|---|---|---|---|---|
| Disclose Problem | 2 (20.33) | 23 (20.33) | 36 (20.33) | 61 |
| Hide Problem | 71 (52.67) | 50 (52.67) | 37 (52.67) | 158 |
| Total | 73 | 73 | 73 | 219 |
\(\chi^2 = \frac{(2 - 20.33)^2}{20.33} + \frac{(23 - 20.33)^2}{20.33} + \frac{(36 - 20.33)^2}{20.33} + \frac{(71 - 52.67)^2}{52.67} + \frac{(50 - 52.67)^2}{52.67} + \frac{(37 - 52.67)^2}{52.67} = 35.86\)
The chi-squared test for goodness-of-fit is used to test whether the observed distribution of a categorical variable (with \(k\) levels) differs from an expected distribution. \[X^2 = \sum_{i=1}^k \frac{(O_i - E_i)^2}{E_i} \overset{\text{approx.}}{\sim} \chi^2_{k-1}\text{ under } H_0\] where \(E_i = n \times p_i\) is the expected count for category \(i\) under \(H_0\).
The chi-squared test for independence is used to test whether there is an association between two categorical variables. \[X^2 = \sum_{i=1}^{R} \sum_{j=1}^{C} \frac{(O_{ij} - E_{ij})^2}{E_{ij}} \overset{\text{approx.}}{\sim} \chi^2_{(R-1)(C-1)}\text{ under } H_0\] where \(E_{ij} = n \times P(\text{row } i) \times P(\text{column } j)\) is the expected count for cell \((i, j)\) under \(H_0\).
It is important to check the assumptions of the chi-squared tests, such as having a sufficiently large sample size and expected counts in each category.

STAT1003 – Statistical Techniques