discrepancy is a Stata add-on that calculates Studer et al's (Sociological Methods and Research) measure of the discrepancy of a distance matrix, grouped by a categorical variable groupvar. The pseudo-R-squared and pseudo-F statistic are based on the extent to which the average distance to the centres of the groups are less than the average distance to the centre of the ungrouped distance matrix.