K-S Subcommand (Two-Sample) (NPAR TESTS command)

NPAR TESTS K-S=varlist BY variable(value1,value2)

K-S (alias KOLMOGOROV-SMIRNOV) tests whether the distribution of a variable is the same in two independent samples that are defined by a grouping variable. The test is sensitive to any difference in median, dispersion, skewness, and so forth, between the two distributions. The output shows the valid number of cases in each group in the Frequency table. The output also shows the largest absolute, positive, and negative differences between the two groups, the Kolmogorov-Smirnov Z, and the two-tailed probability for each variable in the Test Statistics table.

Syntax

  • The minimum specification is a test variable, the keyword BY, a grouping variable, and a pair of values in parentheses.
  • The test variable should be at least at the ordinal level of measurement.
  • Cases with the first value form one group, and cases with the second value form the other group. The order in which values are specified determines which difference is the largest positive and which difference is the largest negative.

Operations

  • The observed cumulative distributions are computed for both groups, as are the maximum positive, negative, and absolute differences. A test statistic is calculated for each variable that is named before BY.
  • Cases with values other than values that are specified for the grouping variable are excluded.

Example

NPAR TESTS K-S=V1 V2 BY V3(0,1).
  • This example specifies two tests. The first test compares the distribution of V1 for cases with value 0 for V3 with the distribution of V1 for cases with value 1 for V3.
  • A parallel test is calculated for V2.