- Introduced by
- John C. Gower
- Year
- 1971
- Type
- General similarity coefficient for multivariate data
- Family
- Mixed-type distance metric
What does it do?
Gower's general coefficient of similarity compares observations whose variables mix types: continuous, ordinal, nominal and binary.
It returns a similarity between 0 (no similarity) and 1 (identical), and the Gower distance is 1 minus this similarity. Introduced by John C. Gower in 1971, it scores each variable on a common 0 to 1 scale before averaging, and it leaves out missing comparisons pair by pair rather than imputing them.
The intuition behind the method
Consider a dataset with mixed information: some measurements (continuous), some rankings (ordinal), some categories (nominal), and some yes/no indicators (binary). Gower's approach is to compute a partial similarity for each variable according to its type, scale each partial similarity to 0 to 1, and average across the variables. Two observations that share categories and have close measurements get a high similarity, while observations that differ in category or in measurements get a low one. Because every variable enters on the same scale, no single variable dominates the result only because of its units.
History
John C. Gower introduced the coefficient in 1971 to compare objects described by mixed data types. The coefficient has since been used in cluster analysis and classification.
When to use it
Choose Gower distance when the observations are described by variables of different types, such as customer profiles with income (continuous), education level (ordinal), location (nominal) and subscription status (binary), and when you do not want to convert all variables to one type. It fits clustering, classification and nearest-neighbour methods on such data, and it can be used when some values are missing. Do not use it when all variables are continuous or all are binary, since single-type metrics such as Euclidean distance or Jaccard-type similarity are simpler for those cases. It is also a poor choice when missing values are systematically related to the variables being compared, because the exclusion rule then removes comparisons in a non-random way.
Limitations and considerations
- The unweighted coefficient gives every variable the same weight in the average, so a variable that matters more counts no more than one that matters less unless weights are specified.
- A nominal variable contributes only 0 or 1: two different levels are equally dissimilar whether or not they are conceptually close, so the coefficient cannot reflect graded differences between categories.
- A pair's distance rests only on the variables observed for both observations, so pairs with few shared observed variables are compared on less evidence.
- Each pair requires per-variable, type-specific handling, so the computation is more involved than applying one formula to numeric columns, and the work grows with the number of observations and variables.
Source conditions do not replace independent scientific review or validation by an analysis engine.
Strengths
- Accepts continuous, ordinal, nominal and binary variables in one coefficient, so variables do not need to be converted to a single type first.
- Every partial similarity lies on the same 0 to 1 scale, so variables measured in different units contribute on a comparable footing.
- Missing comparisons are dropped pair by pair instead of being imputed, which avoids inventing values; the exclusion is unbiased only if missingness is unrelated to the values, as the FAQ notes.
Applications
- Customer segmentation and clustering: grouping customers by mixed attributes (income, age, behavior, location, preferences)
- Biological and ecological classification: comparing organisms by morphological (continuous), behavioral (categorical), and environmental (ordinal) traits
- Record linkage and deduplication: matching individuals across databases with heterogeneous identifiers and attributes
- Quality control and product comparison: comparing products with mixed specification types (dimensions, color, material, certifications)
- Social science and survey analysis: clustering respondents by mixed survey responses (rating scales, multiple choice, ordinal or nominal coding of other answers)
How it works
How it works
For each variable, compute a normalised difference between the two observations on a 0 to 1 scale, according to its type: for a continuous variable, the absolute difference divided by the variable's range; for an ordinal variable, the rank difference divided by the range of ranks; for a nominal or binary variable, 0 if the two values match and 1 if they differ.
Convert each normalised difference into a partial similarity so that 1 means agreement and 0 means maximal disagreement: for continuous and ordinal variables, the partial similarity is one minus the normalised difference; for nominal and binary variables, a match gives 1 and a mismatch gives 0.
Average the partial similarities over the variables observed for both observations; a comparison involving a missing value is left out of both the sum and the count. The Gower distance is then 1 minus this average similarity.
Common pitfalls
- Declaring an ordinal variable as continuous treats the gap between adjacent ranks as equal to any other gap; ordinal variables should use the rank-based partial similarity.
- Using equal weights when some variables are known to matter more; the weighted form exists, but the weights must be chosen and justified for the application.
- Reading a large distance as true dissimilarity when it may reflect missing data: a pair with few shared observed variables can receive a distance that rests on little information, so check how many variables were compared for each pair.
- Applying it to purely continuous or purely binary data, where single-type metrics such as Euclidean distance or Jaccard similarity (see the related pages) are the usual choice.
- Treating sparse binary indicators as symmetric: a symmetric match rule counts joint absences (both observations lacking the feature) as agreement, which can inflate similarity for sparse flags such as subscription or product ownership. For asymmetric binary variables, where joint absence carries no information, a common Gower convention is to leave joint-absence matches out of both the numerator and the denominator.
Frequently asked questions
How does Gower handle categorical variables with many levels?
Gower treats each categorical variable as a match or mismatch, so two observations either share a level (partial similarity 1) or do not (0). Different levels are equally dissimilar whether or not they are conceptually close. If many levels are rare or closely related, consider collapsing them before computing the distance, or down-weighting the variable to limit its influence.
Can I weight different variables in Gower distance?
Yes. Weighted Gower distance multiplies each partial similarity by a weight before averaging, which lets you emphasise variables that are more relevant for your application. The average is taken over the weights of the variables observed for the pair, so only the relative size of the weights matters; weights that sum to 1 are a convenient convention rather than a requirement. When some variables are missing for a pair, the average is renormalised over the remaining weights, so check that the variables still left in the comparison carry the influence you intended.
How does Gower deal with missing values?
When either observation in a pair is missing a value for a variable, that variable is excluded from the calculation for that pair, and the average is taken over the remaining variables. This avoids imputed values, but it is unbiased only if the data are missing at random. If missingness depends on the values themselves, the excluded comparisons differ systematically from the included ones.
Is Gower distance suitable for high-dimensional data?
Gower can be applied to many variables, but each pair requires per-variable work, so computation grows with the size of the data. Whether it performs well depends on the mix of variable types: if the variables are mainly continuous, a simpler numeric metric may suffice. Test its practical performance on your own dataset.
Sources
Gower, J. C. (1971). A general coefficient of similarity and some of its properties. Biometrics, 27(4), 857-874.
Open DOI referenceGower, J. C. (1985). Properties of Euclidean and non-Euclidean distance matrices. Linear Algebra and its Applications, 67, 81-97.
Open DOI reference