Advanced tables and statistics > Descriptive statistics > Non-parametric tests on frequencies > Kolmogorov-Smirnov test
 
Kolmogorov-Smirnov test
Quick reference
To request a Kolmogorov-Smirnov test, type:
stat=ks
on the tab statement.
More information
The Kolmogorov-Smirnov statistic is a table-level statistic. It may be used to compare the cumulative frequency distributions of two samples to test whether they are from the same population. For example, you might want to compare frequency of shopping in Safeway with frequency of shopping in Sainsbury to test whether one frequency increases more rapidly than the other.
To request a Kolmogorov-Smirnov test, include the option stat=ks on the tab statement. The table must have three columns only: the first must be the base column, and the other two columns divide the sample into the two groups to be compared. For example, in the shopping survey the table would require a base column and a column for each supermarket.
The first row of the table must be the base row, while the other rows represent some ordered classification of the respondents (numbers, numeric ranges, or measurements on some ordered scale) listed in increasing order of magnitude.
Notes for this test are:
Both the row and column axes must contain only elements which are mutually exclusive.
When the rows comprise numeric ranges, remember that the test is based only on the figures in the table, and therefore the more information there is in the table, the more powerful the test is. In other words, the more categories the better — you can lose information by collapsing data too much into a few large categories. The counts in the cells of the table can be small, even zero.
This test uses the sum of totalizable rows rather than the figures in the base row in its calculation.
For an example, expand on the shopping survey we mentioned just now. Suppose you want to compare frequency of shopping between a sample of people who shop at Sainsbury and a sample who shop at Safeway, and you want to know, not whether the average number of visits differ, but whether the distributions themselves differ. A Kolmogorov-Smirnov test is appropriate:
tab freq shop;stat=ks
ttlMonthly frequency of shopping at ....
ttlBase: All respondents
l freq
val 157;Base;1–3 times;4–6 times;7–9 times;10 or more times
l shop
col 167;Base;Sainsbury;Safeway
produces:
Monthly frequency of shopping at ....
Base: All respondents
Base   Sainsbury   Safeway
Base 605 304 301
Once 54 24 29
Twice 82 46 36
3 Times 129 65 64
4 Times 194 93 101
5-7 Times 91 51 40
8 or more times 55 24 31

KOLMGOROV - SMIRNOV VALUE = 0.120
SIGNIFICANCE LEVEL = 0.942
The results of this test show a significance level that is close to 1. This indicates that there is little evidence to suggest a difference between the frequency distributions for the two supermarkets.
See also
Non-parametric tests on frequencies