IMSL_KOLMOGOROV1

Syntax | Return Value | Arguments | Keywords | Discussion | Example | Version History

The IMSL_KOLMOGOROV1 function performs a Kolmogorov-Smirnov one-sample test for continuous distributions.

Note
This routine requires an IDL Advanced Math and Stats license. For more information, contact your ITT Visual Information Solutions sales or technical support representative.

Syntax

Result = IMSL_KOLMOGOROV1(f, x [, DIFFERENCES=variable] [, /DOUBLE] [, NMISSING=variable])

Return Value

One-dimensional array of length 3 containing Z, p1, and p2 .

Arguments

f

A scalar string specifying a user-supplied function to compute the cumulative distribution function (CDF) at a given value. The function f must accept a scalar input argument and return the computed value at that point.

x

A one-dimensional array containing the observations.

Keywords

DIFFERENCES

Named variable into which an array containing Dn , Dn+, Dn- is stored.

DOUBLE

If present and nonzero, double precision is used.

NMISSING

Named variable into which the number of missing values is stored.

Discussion

The IMSL_KOLMOGOROV1 function performs a Kolmogorov-Smirnov goodness-of-fit test in one sample. The hypotheses tested follow:

IMSL_KOLMOGOROV1-05.jpg

where F is the cumulative distribution function (CDF) of the random variable, and the theoretical CDF, F* , is specified via the supplied function f. Let n = N_ELEMENTS(x) - Nmissing. The test statistics for both one-sided alternatives:

IMSL_KOLMOGOROV1-06.jpg

and:

IMSL_KOLMOGOROV1-07.jpg

and the two-sided (Dn = Differences(0)) alternative are computed as well as an asymptotic z-score (Result(0)) and p-values associated with the one-sided (Result(1)) and two-sided (Result(2)) hypotheses. For n > 80, asymptotic p-values are used (see Gibbons 1971). For n ≤ 80, exact one-sided p-values are computed according to a method given by Conover (1980, page 350). An approximate two-sided test p-value is obtained as twice the one-sided p-value. The approximation is very close for one-sided p-values less than 0.10 and becomes very bad as the one-sided p-values get larger.

Programming Notes

  1. The theoretical CDF is assumed to be continuous. If the CDF is not continuous, the statistics:
  2. IMSL_KOLMOGOROV1-08.jpg

    will not be computed correctly.

  3. Estimation of parameters in the theoretical CDF from the sample data will tend to make the p-values associated with the test statistics too liberal. The empirical CDF will tend to be closer to the theoretical CDF than it should be.
  4. No attempt is made to check that all points in the sample are in the support of the theoretical CDF. If all sample points are not in the support of the CDF, the null hypothesis must be rejected.

Example

In this example, a random sample of size 100 is generated via routine IMSL_RANDOM for the uniform (0, 1) distribution. We want to test the null hypothesis that the CDF is the standard normal distribution with a mean of 0.5 and a variance equal to the uniform (0, 1) variance (1/12).

.RUN 
FUNCTION l_Cdf,  x 
   mean  =  0.5 
   std  =  0.2886751 
   z  =  (x - mean)/std 
   val  =  IMSL_NORMALCDF(z) 
   RETURN, val 
END 
 
IMSL_RANDOMOPT, set  =  123457 
x  =  IMSL_RANDOM(100, /UNIFORM) 
stats  =  IMSL_KOLMOGOROV1('l_cdf', x, DIFFERENCES = d, $ 
   NMISSING = nm) 
PRINT, 'D  =', d(0) 
PRINT, 'D+ =', d(1) 
PRINT, 'D- =', d(2) 
PRINT, 'Z  =', stats(0) 
PRINT, 'Prob greater D one sided =', stats(1) 
 
D  =     0.147083 
D+ =    0.0809559 
D- =     0.147083 
Z  =      1.47083 
Prob greater D one sided =    0.0132111 

Version History

6.4

Introduced