2
$\begingroup$

I am interested in clustering a mixed type dataset and therefore I have found the package "clustMixType" in R Link to package description. I want to cluster numerical, categorical and ordinal variables. My original data set has an ordinal unequal size interval variable age (0 - 12, 13 - 18, 19 - 25, 26 - 90) which is problematic to cluster due to its nature.

The linked package description includes some generated data set:

datasim <- function(n = 100, k.ord = 2, muk = 1.5){
clusid <- rep(1:4, each = n)
# numeric
mus <- c(rep(-muk, n),
rep(-muk, n),
rep(muk, n),
rep(muk, n))
x1 <- rnorm(4*n) + mus
# ordered factor
mus <- c(rep(-muk, n),
rep(muk, n),
rep(-muk, n),
rep(muk, n))
x2 <- rnorm(4*n) + mus
# ordered factor
quants <- quantile(x2, seq(0, 1, length.out = (k.ord+1)))
quants[1] <- -Inf
quants[length(quants)] <- Inf
x2 <- as.ordered(cut(x2, quants))
x <- data.frame(x1, x2)
return(x)
}
n <- 100
x <- datasim(n = n, k.ord = 10, muk = 2)

Have I understood it correctly that in the generated data set from above, the "x2" variable is a an ordered, categorical variable with levels representing unequal intervals? The author then procedes to use Gower's distance on the generated data set.

Is there anything one can do to cluster an ordinal variable that is also of unequal interval size (like my age variable)? I have been thinking of turning the age variable into a categorical ordinal variable with levels 1,2,3,4 even though it means loss of information. Can one do that?

$\endgroup$

1 Answer 1

1
$\begingroup$

There are different kinds of ordinal variables. Your variable has an underlying ratio scaled variable age and therefore holds more quantitative information than ordinal variables where no such underlying variable is known. With use in Gower's distance my first impulse would be to use this as a quantitative variable where you score each age category by its midpoint. If you have information about the within-class distributions of age you can do better, for example use the mean or compute the midpoint for the highest age class using the maximum of 80 if you know nobody older than 80 is in the sample (just as an example for use of information if you know such a thing).

The standard approach for ordinal data in Gower would be to score the categories 1,2,3,4 as you write, and indeed this loses some information which is retained with the scheme above. The computation of Gower's distance, although advertised as suitable for ordinal data, in fact doesn't do any reasoning that is specifically ordinal, it does a quantitative computation with scores, and these scores are chosen 1,2,3,4 as default in absence of any better information. If you have better information, use it (see above).

A proviso is that in general I recommend that the distance you use should reflect the meaning of the data relative to the clustering aim. Using midpoints of age ranges would score you categories as 6, 15.5, 22, 58. This implies that the effective distance between the 26-90 and 19-25 categories is much larger than the effective distances between the younger categories. If in your situation you have reasons to think that most relevant development happens at young age and there is really not that much going on anymore at higher age that is relevant to your problem, you may prefer coding as 1,2,3,4 because this makes the effective distance between any two neighbouring classes the same, which may well reflect how age actually works in your situation. Regarding the resulting clustering, this will have the effect that there is less tendency to isolate the highest age group and separate it from the others. This may well be appropriate but depends on whether in terms of what you are interested in age should rather count in a quantitative way, or whether its effect flattens out with age and therefore you would not want to treat the larger ages as "quantitatively" remote from 19-25, say.

If you start to think more about this, based on even more background information that you might have, you may well end up thinking that you'd want a scoring that is different from both scorings mentioned up to now, i.e., neither 6, 15.5, 22, 58 nor 1,2,3,4. This is fair enough if you have the expertise and good arguments, however the two scorings mentioned above have the advantage that they are "easy to establish and defend", so to say, whereas if you chose an even different one, you'd need to work harder to convince your audience that and why your specific choice makes sense.

Regarding the R-code in the question, by the way, my arguments make reference to the meaning of the data, and simulated data have no meaning. One can simulate data from the same ordinal distribution using a different (from normal) underlying latent distribution and different intervals, even of same length if you want, so as long as there is no relevant meaning of the variables is involved, it is not mathematically identifiable what the "true" underlying intervals are and whether they are of same length or not.

I should also say that my comments specifically apply to Gower's distance and any approach which treats ordinal variables as quantitative variables with specific scores, in which case you can manipulate the scores in this way, but there are methods that treat ordinal variables differently.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.