ks.test                package:stats                R Documentation

_K_o_l_m_o_g_o_r_o_v-_S_m_i_r_n_o_v _T_e_s_t_s

_D_e_s_c_r_i_p_t_i_o_n:

     Performs one or two sample Kolmogorov-Smirnov tests.

_U_s_a_g_e:

     ks.test(x, y, ..., alternative = c("two.sided", "less", "greater"),
             exact = NULL)

_A_r_g_u_m_e_n_t_s:

       x: a numeric vector of data values.

       y: either a numeric vector of data values, or a character string
          naming a distribution function.

     ...: parameters of the distribution specified (as a character
          string) by 'y'.

alternative: indicates the alternative hypothesis and must be one of
          '"two.sided"' (default), '"less"', or '"greater"'.  You can
          specify just the initial letter.

   exact: 'NULL' or a logical indicating whether an exact p-value
          should be computed.  See Details for the meaning of 'NULL'.
          Only used in the two-sided two-sample case.

_D_e_t_a_i_l_s:

     If 'y' is numeric, a two-sample test of the null hypothesis that
     'x' and 'y' were drawn from the same _continuous_ distribution is
     performed.

     Alternatively, 'y' can be a character string naming a continuous
     distribution function.  In this case, a one-sample test is carried
     out of the null that the distribution function which generated 'x'
     is distribution 'y' with parameters specified by '...'.

     The presence of ties generates a warning, since continuous
     distributions do not generate them.

     The possible values '"two.sided"', '"less"' and '"greater"' of
     'alternative' specify the null hypothesis that the true
     distribution function of 'x' is equal to, not less than or not
     greater than the hypothesized distribution function (one-sample
     case) or the distribution function of 'y' (two-sample case),
     respectively.

     Exact p-values are only available for the two-sided two-sample
     test with no ties.  In that case, if 'exact = NULL' (the default)
     an exact p-value is computed if the product of the sample sizes is
     less than 10000.  Otherwise, asymptotic distributions are used
     whose approximations may be inaccurate in small samples.

     If a single-sample test is used, the parameters specified in '...'
     must be pre-specified and not estimated from the data. There is
     some more refined distribution theory for the KS test with
     estimated parameters (see Durbin, 1973), but that is not
     implemented in 'ks.test'.

_V_a_l_u_e:

     A list with class '"htest"' containing the following components: 

statistic: the value of the test statistic.

 p.value: the p-value of the test.

alternative: a character string describing the alternative hypothesis.

  method: a character string indicating what type of test was
          performed.

data.name: a character string giving the name(s) of the data.

_R_e_f_e_r_e_n_c_e_s:

     William J. Conover (1971), _Practical nonparametric statistics_.
     New York: John Wiley & Sons. Pages 295-301 (one-sample
     "Kolmogorov" test), 309-314 (two-sample "Smirnov" test).

     Durbin, J. (1973) _Distribution theory for tests based on the
     sample distribution function_.  SIAM.

_S_e_e _A_l_s_o:

     'shapiro.test' which performs the Shapiro-Wilk test for normality.

_E_x_a_m_p_l_e_s:

     x <- rnorm(50)
     y <- runif(30)
     # Do x and y come from the same distribution?
     ks.test(x, y)
     # Does x come from a shifted gamma distribution with shape 3 and scale 2?
     ks.test(x+2, "pgamma", 3, 2) # two-sided
     ks.test(x+2, "pgamma", 3, 2, alternative = "gr")

