← Back to Statistics

Tests for means and proportions

The same logic adapts to the most common situations: testing a mean with unknown spread, a proportion, and differences between groups.

The one-sample t test

In practice \(\sigma\) is unknown, so use the sample standard deviation \(s\) and the t distribution with \(n - 1\) degrees of freedom: \(t = \frac{\bar{x} - \mu_0}{s/\sqrt{n}}\). The t test is reliable for roughly symmetric data or samples of about 30 or more, even if the data are somewhat skewed.

t = \frac{\bar{x} - \mu_0}{s/\sqrt{n}}

Worked example: a t test

A sleep study of 16 students gives \(\bar{x} = 6.6\) hours and \(s = 1.2\). Is the mean below the recommended 7 hours? \(t = \frac{6.6 - 7}{1.2/4} = -1.33\) with 15 degrees of freedom gives a one-sided p-value of about 0.10. At \(\alpha = 0.05\), we fail to reject \(H_0\): the evidence is suggestive but not convincing with this sample size.

The one-proportion z test

For a proportion, \(z = \frac{\hat{p} - p_0}{\sqrt{p_0(1-p_0)/n}}\), using the null value \(p_0\) in the standard error. Conditions: a random sample and \(np_0\) and \(n(1 - p_0)\) at least 10. If 58 of 100 customers prefer a new design, test \(p = 0.5\): \(z = \frac{0.08}{0.05} = 1.6\), two-sided \(p \approx 0.11\).

z = \frac{\hat{p} - p_0}{\sqrt{p_0(1-p_0)/n}}

Comparing two means

The two-sample t test compares independent groups, such as a treatment group and a control group, using \(t = \frac{\bar{x}_1 - \bar{x}_2}{\sqrt{s_1^2/n_1 + s_2^2/n_2}}\). Paired data, such as before-and-after measurements on the same people, should instead be analysed with a one-sample t test on the differences, which removes person-to-person variation.

Comparing two proportions

To compare success rates, such as vaccine versus placebo infection rates, use a two-proportion z test with a pooled proportion under \(H_0: p_1 = p_2\). Clinical trials and A/B tests of websites rely heavily on this test.

Chi-square tests

For categorical data with several categories, the chi-square statistic \(\sum \frac{(\text{observed} - \text{expected})^2}{\text{expected}}\) measures how far counts depart from expectations. A goodness-of-fit test checks one variable against a claimed distribution; a test of independence checks whether two categorical variables are associated.

\chi^2 = \sum \frac{(O - E)^2}{E}

Checking conditions

Every test assumes random sampling or random assignment, independence of observations (often checked by the sample being under 10% of the population), and a sampling distribution of the right shape. Violating conditions can make p-values meaningless, no matter how carefully they are computed.

Multiple testing

If you run 20 tests at \(\alpha = 0.05\) when no effects exist, you expect about one false positive. Searching many variables until something is significant, sometimes called p-hacking, produces unreliable findings. Corrections like Bonferroni (dividing \(\alpha\) by the number of tests) help control this.

Key takeaways

Use the t test for means with unknown \(\sigma\), the z test for proportions, two-sample methods for independent groups, paired t tests for matched data, and chi-square tests for categorical counts. Check conditions, and beware of multiple testing.

Flashcard

One-sample t test

t = \frac{\bar{x}-\mu_0}{s/\sqrt{n}}

df = n - 1.

Check your understanding

Researchers measure blood pressure on 25 patients before and after a drug. Which test fits?

← Previous lesson Next lesson →