Page 202 - Applied Statistics Using SPSS, STATISTICA, MATLAB and R
P. 202

5.1 Inference on One Population   183


           Commands 5.4.  SPSS,  STATISTICA,  MATLAB and R commands  used to
           perform the chi-square goodness of fit test.

             SPSS          Analyze; Nonparametric Tests; Chi-Square

                           Statistics; Nonparametrics; Observed
             STATISTICA                         2
                           versus expected    Χ .
             MATLAB        [c,df,sig] = chi2test(x)

             R             chisq.test(x,p)


           MATLAB does not have a specific function for the chi-square test. We provide in
           the book CD the  chi2test   function for that purpose.


           5.1.4 The Kolmogorov-Smirnov Goodness of Fit Test

           The  Kolmogorov-Smirnov  goodness  of fit test is a one-sample test designed to
           assess the goodness  of fit of a data sample to a hypothesised continuous
           distribution, F X (x). The null hypothesis is formalised as:

              H 0: Data variable X has a cumulative probability distribution F X (x) ≡ F(x).

              Let  S n(x) be the  observed cumulative distribution  of the random sample,  x 1,
           x 2,…, x n, also called empirical distribution. Assuming the sample data is sorted in
           increasing order,  the values  of  S n(x) are obtained  by adding the successive
           frequencies of occurrence, k i/n, for each distinct x i.
              Under the null hypothesis one expects to obtain small deviations of S n(x) from
           F(x). The  Kolmogorov-Smirnov test  uses the largest  of such deviations as a
           goodness of fit measure:

              D n = max | F(x) − S n(x) |, for every distinct x i.         5.10

              The sampling distribution of D n is given in the literature. Unless n is very small
           the following asymptotic result can be used:

              lim P (  D  ≤ t ) n  =1 − 2 ∑ ∞  ( − ) i −1 e −2 ti 2  2  .  5.11
                                        1
              n → ∞     n           i =1

              The Kolmogorov-Smirnov test rejects the null hypothesis at level  α if

           D n >  d  α , n  , where d  α , n   is such that:

              P  (D  > d  ) = α .                                          5.12
               H 0  n    α , n

              Using formula 5.11 the following critical points are obtained:

              d n . 01  =  . 1  63 /  n;  d n . 05  =  . 1  36  /  n;  d n . 10  =  . 1  22  /  n .  5.13
                                                      ,
                                                      0
                ,
                                   ,
                                   0
                0
   197   198   199   200   201   202   203   204   205   206   207