help discrepancy

Title

discrepancy -- Calculate Studer et al's discrepancy measure

Syntax

discrepancy groupvar , DISTmat(string) IDvar(varname) [NITer(integer 100) DCG(string)]

options

Required
distmat(matname) names the distance matrix

idvar(varname) identifies the variable that links the sort-order of the distance matrix to the sort-order of the data

Optional
niter(interger) number of permutations used to calculate p-value, defaults to 100

dcg(string) variable in which to store the distance to the group centre

Description

discrepancy calculates Studer et al's 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. The p-value is based on permutations (100 by default,
but Studer et al recommend 1000 to 5000; set it to 1 for speed if you
are not interested in the p-value).

The distance to the centre of the group can optionally be saved in
a variable. This can be used to identify group medoids.

Returns:

r(p_perm)

r(pseudoF)

r(pseudoR2)

References

M Studer, G Ritschard, A Gabadinho and NS Müller, Discrepancy analysis of state sequences,
Sociological Methods and Research, 40(3):471-510

Author

Brendan Halpin, brendan.halpin@ul.ie

Examples

. discrepancy sex, dist(d) id(id) dcg(dsex)

. bysort sex: egen mindist = min(dsex)

. gen medoid = mindist == min(dsex)