MIT 18.650 — Lecture 18

Goodness of Fit and T Tests

§ The Chi-Squared Distribution

Definition. A random variable XX is said to have “a χ2 distribution with k degrees of freedom”\underline{\text{``a }\chi^2\text{ distribution with }k\text{ degrees of freedom''}}, denoted Xχk2X \sim \chi_k^2, if and only if XX is distributed as Z12++Zk2Z_1^2 + \dots + Z_k^2, where {Zi}i=1k\{Z_i\}_{i = 1}^k are i.i.d. samples from N(0,1)\mathcal{N}(0, 1).

Note that E[X]=k\mathbb{E}[X] = k and V[X]=2k\mathbb{V}[X] = 2k if Xχk2X \sim \chi_k^2.

Definition. The upper α\alpha quantile of the χk2\chi_k^2 distribution is denoted χk,α2\chi^2_{k, \alpha}, where P(X>χk,α2)=α\mathbb{P}(X > \chi^2_{k, \alpha}) = \alpha given Xχk2X \sim \chi_k^2.

§ Goodness of Fit Tests

Suppose we have a random variable XX that takes on kk discrete values {1,2,,k}\{1, 2, \dots, k\}. For example, XX might be the color of a randomly selected jellybean, either red, green, blue, or black.

Suppose such a random variable XX has a true PMF f:{1,2,,k}[0,1]f: \{1, 2, \dots, k\} \to [0, 1] and an expected PMF f0f_0. A goodness of fit test determines whether H0:f=f0H_0 : f = f_0 or H1:ff0H_1: f \neq f_0.

Theorem. (Pearson's χ2\chi^2 GoF Test) Suppose we seek a goodness of fit test with level α\alpha as described above, and our data consists of nn samples {Xi}i=1n\{X_i\}_{i = 1}^n taken (i.i.d.) from XX.

Then our test statistic is Tn:=j=1k(OjEj)2EjT_n := \sum_{j = 1}^k \frac{(O_j - E_j)^2}{E_j}, we claim that under H0H_0, we have Tnχk12T_n \rightsquigarrow \chi_{k - 1}^2 as nn \to \infty, and our test is Ψ:=1(Tn>χk1,α2)\Psi := \mathds{1}(T_n > \chi_{k - 1, \alpha}^2).

Proof: The mathematically-nontrivial part of this test is the claim that Tnχk12T_n \rightsquigarrow \chi_{k - 1}^2 as nn \to \infty. The proof of this claim is fairly computationally intensive, so we omit it here. (18.650 does not cover it.)   \blacksquare

§ The T-Test

Recall that the Wald test for population means relies on the following two approximations:

  1. The test statistic Tn:=Xˉnμσ/nT_n := \frac{\bar{X}_n - \mu}{\sigma / \sqrt{n}} is approximately N(0,1)\mathcal{N}(0, 1) by the CLT.

  2. We can approximate σσ^:=sn2\sigma \approx \hat{\sigma} := \sqrt{s_n^2} by the LLN, CLT, and Slutsky's. (See Lectures 1-3 notes.)

Suppose that our population distribution is normal: XN(μ,σ2)X \sim \mathcal{N}(\mu, \sigma^2). Then approximation #1 holds—it's not even an approximation! But for small nn, approximation #2, which says TnXˉnμσ^/nT_n \approx \frac{\bar{X}_n - \mu}{\hat{\sigma} / \sqrt{n}}, needs refinement.

Theorem. (T-Test) Suppose X1,,XnN(μ,σ2)X_1, \dots, X_n \sim \mathcal{N}(\mu, \sigma^2) (i.i.d.) and σ^2=1n1i=1n(XiXˉn)2\hat{\sigma}^2 = \frac{1}{n - 1} \sum_{i = 1}^n (X_i - \bar{X}_n)^2. Then we have:

Xˉnμσ^/ntn1       where       tν has PDF f(x):=Γ(ν+12)νπΓ(ν2)(1+x2ν)(ν+1)/2.\frac{\bar{X}_n - \mu}{\hat{\sigma} / \sqrt{n}} \sim t_{n - 1} ~~~~~~ \text{ where } ~~~~~~ t_{\nu} \text{ has PDF } f(x) := \frac{ \Gamma\left(\frac{\nu + 1}{2}\right) }{ \sqrt{\nu\pi} \cdot \Gamma\left(\frac{\nu}{2}\right) } \left(1 + \frac{x^2}{\nu}\right)^{-(\nu + 1)/2}.

We say that tνt_{\nu} is the Student's t-distribution (named after the pseudonym “Student” used by William Sealy Gosset).

Again, we won't give the mathematical justification as it gets too involved.