The theoretical distribution function \(F_0(x)\) and the empirical distribution function \(F_n^*(x)\) for a sample of size \(n=12\). The Kolmogorov statistic \(D_n=\sup_x|F_n^*(x)-F_0(x)|\) is marked on the graph.
Goodness-of-Fit Tests
This text is still being edited: it may contain typos, inaccuracies, and locally unpolished passages. If you find something, please let the author know (contact information on the course page).
The next class of hypotheses that we consider in this text concerns whether an unknown distribution coincides with a known one. In other words, let \(X\) be an observation with unknown distribution \(\mathbb {P}\), whose distribution function equals \(F\). We pose the hypotheses
\[ H_0: \; \mathbb {P} = \mathbb {P}_0, \qquad H_1: \; \mathbb {P} \neq \mathbb {P}_0 \]
for some given distribution \(\mathbb {P}_0\). The alternative distributions are left entirely unspecified; a priori only the type of distribution (e.g. discrete or absolutely continuous) and the set of possible values of the observation \(X\) may be known. Tests for such hypotheses are called goodness-of-fit tests. The best known among them are the Kolmogorov test and the chi-squared test, which we discuss in this chapter. The first is based on comparing the theoretical and empirical distribution functions, and the second on comparing the theoretical and empirical densities.
For goodness-of-fit tests it is customary to use ones that have the property of consistency.
1 Comparing the theoretical and empirical distribution functions
Let \(X=\left(X_{1}, \ldots , X_{n}\right)\) be a sample from an unknown distribution on \(\mathbb {R}\) with continuous distribution function \(F\). We construct a test for the hypothesis \(H_{0}: \mathbb {P}=\mathbb {P}_{0}\). If \(F_0\) is the distribution function of \(\mathbb {P}_0\), then \(H_0\) can be equivalently restated as \(H_0: F = F_0\).
1.1 The Kolmogorov goodness-of-fit test
The Kolmogorov statistic is the distance between the functions \(F_n^*\) and \(F_0\) in the supremum metric:
\[ D_n := \sup _{x \in \mathbb {R}}\left|F_n^*(x) - F_{0}(x) \right|. \tag{1}\]
The distribution of \(D_n\) depends only on \(n\), but for finite \(n\) it is given by overly cumbersome formulas. The limiting distribution of the statistic \(D_n\) looks somewhat simpler.
The Kolmogorov test of significance level \(\alpha\) is written as follows: \(\left\{ \sqrt{n} D_{n}> Q_{\operatorname {K}}(1-\alpha )\right\}\), where \(Q_{\operatorname {K}}(\cdot )\) is the quantile function of the Kolmogorov distribution. The Kolmogorov test is asymptotic, since we use not the exact distribution of \(D_n\) for each \(n\), but only the limiting distribution. The Kolmogorov test is customarily applied when \(n \geq 20\).
The density of the Kolmogorov distribution (the limiting distribution of the statistic \(\sqrt n D_n\)).
1.2 The CramΓ©r-von Mises-Smirnov test
The CramΓ©r-von Mises-Smirnov statistic is the squared distance between the functions \(F_n^*\) and \(F_0\) in the space \(L^{2}\left(\mathbb {R}, \mathscr {B}\left(\mathbb {R}\right), \mathbb {P}_0\right)\):
\[ \omega ^2 := \int _{\mathbb {R}} \left|F_n^*(t) - F_0(t)\right|^2 \mathbb {P}_0(dt) = \int _{-\infty }^\infty \left|F_n^*(t) - F_0(t)\right|^2 dF_0(t). \]
The last integral is a Lebesgue-Stieltjes integral.
As with the distribution of the Kolmogorov statistic, the distribution of the statistic \(\omega^2\) does not depend on \(F_0\) when \(H_0\) holds.
As with \(D_n\), the distribution of \(\omega^2\) for finite \(n\) is given by overly cumbersome formulas, but the limiting distribution looks more or less simple.
The CramΓ©r-von Mises-Smirnov test of significance level \(\alpha\) is written as follows: \(\left\{ n \omega^2>Q_{\operatorname {OS}}(1-\alpha )\right\}\), where \(Q_{\operatorname {OS}}(\cdot )\) is the quantile function of the omega-squared distribution. The CramΓ©r-von Mises-Smirnov test, like the Kolmogorov test, is asymptotic, since we use not the exact distribution of \(\omega^2\) for each \(n\), but only the limiting distribution.
2 Comparing the theoretical and empirical densities: the chi-squared test
2.1 A sample from a Bernoulli scheme with known outcomes
Let \(X_{1}, \ldots , X_{n}\) be a sample from a Bernoulli scheme with \(m \geq 2\) known outcomes \(A = \left\{ a_1, \ldots , a_m\right\}\). The probability mass function (a generalized density with respect to the counting measure on \(A\)):
\[ p_j := \mathbb {P}\left(X_1 = a_j\right), \; j = \overline{1,m} \]
We know the outcomes \(a_1, \ldots , a_m\), but the probabilities \(p_1, \ldots , p_m\) are unknown. Such a distribution is also called categorical and is denoted
\[ \operatorname {Cat}(A, \overrightarrow {p}), \qquad \overrightarrow {p} = \left(p_1, p_2, \ldots , p_m\right)^T \]
Let us estimate the unknown distribution by the empirical distribution. In that case the estimator of \(p_j\) equals the sample frequency of hitting \(a_j\):
\[ \widehat{p_j} = \overline{\; \mathbb {1}_{X = a_j}}, \qquad \widehat{\overrightarrow {p}} = \left(\widehat{p}_1, \widehat{p}_2, \ldots , \widehat{p}_m\right)^T \]
2.1.1 Simple hypothesis
Let \(A\) be a fixed set of outcomes, and consider the following parametric model
\[ \mathcal{P} = \left\{ \operatorname {Cat}(A, \overrightarrow {p}): \; \overrightarrow {p}\in [0,1]^m, \sum _{i=1}^m p_i = 1\right\} . \]
Let \(\overrightarrow {p}^0 \in [0,1]^m\) be a fixed vector such that \(\sum_{i=1}^m p_i = 1\). Consider the parametric hypotheses
\[ H_0: \mathbb {P} = \mathbb {P}_0 = \operatorname {Cat}(A, \overrightarrow {p}^0), \qquad H_1: \mathbb {P} \in \mathcal{P}\setminus \left\{ \mathbb {P}_0\right\} = \left\{ \operatorname {Cat}(A, \overrightarrow {p}): \overrightarrow {p} \neq \overrightarrow {p}^0\right\} \]
Equivalently:
\[ H_0: \overrightarrow {p} = \overrightarrow {p}_0, \qquad H_1 : \overrightarrow {p} \neq \overrightarrow {p}_0 \]
Pearsonβs chi-squared test is written as follows: \(\left\{ \widehat{\chi^2}> Q_{\chi^2_{m-1}}(1-\alpha )\right\}\), where \(Q_{\chi^2_{m-1}}(\cdot )\) is the quantile function of \(\chi_{m-1}^{2}\). The chi-squared test is asymptotic; it is customarily applied when \(n \geq 50\) and \(\mu_{j} \geq 5\) for all \(j \in \{ 1, \ldots , m\}\).
2.1.2 Composite hypothesis
Pearsonβs chi-squared test can also be applied in the case of composite hypotheses
\[ H_0: \overrightarrow {p} = \overrightarrow {p}^0(\overrightarrow {\theta }), \; \overrightarrow {\theta } \in \Theta \subset \mathbb {R}^{r}, \; r < m-1, \qquad H_1: \overrightarrow {p} \neq \overrightarrow {p}^0(\overrightarrow {\theta }) \]
To test such hypotheses one also uses the statistic \(\widehat{\chi^2} = \widehat{\chi^2}(\overrightarrow {\theta })\), in which \(\overrightarrow {\theta }\) is replaced by the maximum likelihood estimator
\[ \overrightarrow {\theta }^{*} = \operatorname *{arg\, max}_{\overrightarrow {\theta } \in \Theta } \prod _{j=1}^{m}\left(p_{j}^{0}(\overrightarrow {\theta })\right)^{\mu _{j}} . \]
2.2 The general case
The chi-squared test, like the Kolmogorov goodness-of-fit test, is used to test the hypothesis that the distribution from which our sample is drawn coincides with some specific distribution \(\mathbb {P}_0\). Unlike the Kolmogorov test, the chi-squared test does not require heavy computation, but is less βprecise.β One can work with the chi-squared test in the case of an arbitrary class of distributions as follows: the range of the sample is partitioned into several intervals, after which the number of sample elements falling into each interval is computed. The resulting values are taken as \(\mu_{j}\). As \(p_{j}^{0}\) one takes the probability that a random variable with distribution \(\mathbb {P}_0\) falls into the \(j\)-th interval. In essence, one compares the histogram of the sample with the theoretical histogram of the distribution \(\mathbb {P}_0\).
On the number of classes, see (Kallenberg et al. 1985).