6.1 The K-S One Sample Test (goodness-of-fit test)
There are several computation methods for the K-S statistic. We follow the commonly used version.
- 1.
- Obtain order statistics.
- 2.
- Compute the assumed distribution \((F_0)\) and the edf \(\widehat {F}_n\) at each data point.
- 3.
- Since the K-S is the distance test, we need to find the maximum distance \(\max |F_0-\widehat {F}_n|\) between the theoretical and edf empirical distribution.
These two functions are defined as \[F_0(X_{(i)})=P(X\leq X_{(i)})=CDF(X_{(i)}),\hspace {0.5cm} i=1,\dots ,n\] \(F_0(X_{(i)})\) is the assumed cdf evaluated at \(X_i\) and \(\widehat {F}_n(X_{(i)})\) is the edf obtained by the proportion of the data smaller \(X_i\) in the data set of size \(n\).
\begin {align*} \widehat {F}_n(X_{(i)}) &=\frac {\text {number}\hspace {0.4cm}X_i\leq X_{(i)}}{n}\\ &=\frac {i}{n}\\ &=\frac {1}{n}\sum ^n_{i=1}I_{\{X_i\leq x\}}\\\\ I &= \begin {cases} 0, & X_i>x\\ 1, &X_i\leq x \end {cases} \end {align*}
Let \(x_1,\dots ,x_n\) be observations on continuous iid random variables \(X_1,X_2,\dots ,X_n\) with cdf \(F\) we want to test the
hypothesis such that \(H_0:F(x)=F_0(x)\) for all values of \(x\) vs \(H_a:F(x)\neq F_0(x)\) for at least one value of \(x\). Where \(F_0\) is the known
cdf.
The K-S statistic
\[D_n=D_n\sup _{x\in \mathbb {R}}|F_n(x)-F_0(x)|\]
where \(F_n(x)\) is as given above \begin {align*} D^+_n &=\max \{F_n(x)-F_0(x_{(i)})\}=\max \Big \{\frac {i}{n}-F_0(x_{(i)})\Big \}\\\\ D^-_n &=\max \{F_0(x_{(i)})-\widehat {F}_n(x_{(i-1)})\}=\max \Big \{F_0(X_{(i)})-\frac {i-1}{n}\Big \}\\\\ D_n &=\max \{D_n^+,D_n^-\}.\\ \end {align*}
Questions on this section
Stuck on something here? Ask below and it stays attached to this topic.