Confidence intervals, chi-square and regression
Introduzido| English | Significado |
|---|---|
| chi-squared test/kaɪ skweəd test/ | A statistical test that compares observed frequencies with frequencies expected under a null hypothesis. |
| confidence interval/ˈkɒnfɪdəns ˈɪntəvl/ | intervalo de confiança |
| central limit theorem/ˈsentrəl ˈlɪmɪt ˈθɪərəm/ | The result that the mean of a large random sample is approximately normally distributed, whatever the population. |
| standard error/ˈstændəd ˈerə/ | The standard deviation of a sample mean, σ/√n. |
| degrees of freedom/dɪˈɡriːz ɒv ˈfriːdəm/ | The number of independent values free to vary after relevant constraints have been imposed. |
Pearson's test of fit, 1900
- In 1900, Karl Pearson at University College London published a single number that measures how far observed counts are from the counts a model predicts. He tested it on 26,306 throws of 12 dice by the zoologist Raphael Weldon, and showed the dice gave too many fives and sixes. His chi-squared test 卡方检验 is still one of the most used tests in science.
- S3 also gives a range of believable values for a population mean: a confidence interval 置信区间.
The distribution of a sample mean
- If $X$ has mean $\mu$ and variance $\sigma^2$, the sample mean of $n$ values has $\bar{X} \sim \mathrm{N}\left(\mu, \dfrac{\sigma^2}{n}\right)$ — exactly for normal $X$, and approximately for large $n$ by the central limit theorem 中心极限定理.
- The standard error 标准误差 $\dfrac{\sigma}{\sqrt{n}}$ shrinks as $n$ grows: 4 times the sample halves it.
$X$ has standard deviation 12. Find the standard error of the mean of a sample of 36.
Dificuldade 2/5 · Moedas 140 + pequeno bônus na primeira conclusão hoje
$\tfrac{12}{\sqrt{36}} = 2$.
Confidence intervals
- A 95% confidence interval for $\mu$ is $\bar{x} \pm 1.96\dfrac{\sigma}{\sqrt{n}}$; for 99% use 2.5758.
- With $\bar{x} = 50$, $\sigma = 5$ and $n = 25$: $50 \pm 1.96 \times 1 = (48.04, 51.96)$. Of many intervals made this way, about 95% contain $\mu$.
A sample of 64 has mean 120, with $\sigma = 16$. Find the upper end of the 95% confidence interval, to 2 d.p.
Dificuldade 2/5 · Moedas 140 + pequeno bônus na primeira conclusão hoje
$120 + 1.96 \times \tfrac{16}{8} = 123.92$.
Which change makes a confidence interval narrower?
Dificuldade 1/5 · Moedas 100 + pequeno bônus na primeira conclusão hoje
A larger $n$ reduces $\tfrac{\sigma}{\sqrt{n}}$.
Worked example: is the die fair?
A die is rolled 120 times, giving 15, 25, 18, 22, 14, 26 for faces 1 to 6. Test at the 5% level whether it is fair.
- Hypotheses: $\mathrm{H}_0$: the die is fair; $\mathrm{H}_1$: it is not. Expected frequencies are all $\tfrac{120}{6} = 20$.
- Statistic: $\chi^2 = \sum\dfrac{(O - E)^2}{E} = \dfrac{25 + 25 + 4 + 4 + 36 + 36}{20} = 6.5$.
- Decision: there are $6 - 1 = 5$ degrees of freedom 自由度, with critical value 11.070. Since $6.5 < 11.070$, do not reject $\mathrm{H}_0$: there is no evidence that the die is biased.
Confidence intervals, chi-square and regression
For a normal mean with known σ, a 95% interval is sample mean±1
Compare the model with the worked case and explain one change.
Observed 30, 50, 20 against expected 40, 40, 20. Find $\chi^2$.
Dificuldade 2/5 · Moedas 140 + pequeno bônus na primeira conclusão hoje
$\tfrac{100}{40} + \tfrac{100}{40} + 0 = 5$.
Contingency tables
- To test whether two factors are independent, the expected frequency in each cell is $\dfrac{\text{row total} \times \text{column total}}{\text{grand total}}$.
- An $r \times c$ table has $(r - 1)(c - 1)$ degrees of freedom: a $3 \times 4$ table has 6.
How many degrees of freedom does a $2 \times 5$ contingency table have?
Dificuldade 2/5 · Moedas 140 + pequeno bônus na primeira conclusão hoje
$(2 - 1)(5 - 1) = 4$.
Degrees of freedom and small cells
- Lose one degree of freedom for each total fixed, and one more for each parameter estimated from the data (for example, $\lambda$ for a Poisson model).
- The test needs every expected frequency to be at least 5; merge neighbouring cells if not, and recount the degrees of freedom.
If a cell has an expected frequency of 3, you should merge it with a neighbouring cell before the test.
Dificuldade 1/5 · Moedas 100 + pequeno bônus na primeira conclusão hoje
Every expected frequency should be at least 5.
"There is a 95% probability that $\mu$ is in this interval." Once the interval is calculated, $\mu$ either is or is not inside it. The 95% describes the method: of all intervals made this way, about 95% would contain $\mu$.
$\bar{X} \sim \mathrm{N}(\mu, \tfrac{\sigma^2}{n})$, so a 95% confidence interval is $\bar{x} \pm 1.96\tfrac{\sigma}{\sqrt{n}}$. The chi-squared statistic is $\sum\tfrac{(O - E)^2}{E}$; find the degrees of freedom (cells − constraints − estimated parameters, or $(r - 1)(c - 1)$), merge cells with $E < 5$, and compare with the critical value.
In a survey of 100 people, 30 of 40 men and 30 of 60 women prefer tea to coffee. Test at the 5% level whether preference is independent of gender (critical value 3.841).
Expected, statistic, compare, conclude.