I am trying to perform cluster analysis on survey data, where each respondent has answered several questions, some of which have categorical answers ("blue", "pink", "green" etc) and some of which have scale answers (rating from 1 to 10 etc).

My problem is that certain age groups were over-sampled and I need to weight the data collected in order to accurately reflect the current population.

Will it make a difference if I do the cluster analysis on the weighted data, and if so, how do I do cluster analysis on the weighted data?

  • $\begingroup$ If you cluster respondents, not variables, weighting of respondents has (quite logically) no effect on the results of most clustering methods; moreover, most methods will just ignore your weighting or force you to switch weighting off. $\endgroup$
    – ttnphns
    Mar 19, 2013 at 15:27
  • $\begingroup$ Also note that depending on the complexity of the stratification, you may require Taylor Series Linearization, maybe. This is quite common if using data from a population-based survey. $\endgroup$
    – Behacad
    Mar 19, 2013 at 19:41
  • 1
    $\begingroup$ If the survey oversampled subjects with respect to covariates that you want in the model, then the model provides proper conditional estimates and you do not need to take sample weights into account. Sample weights are of interest when estimating population quantities (e.g., population mean family income) where you want to average over a heterogeneous collection of individuals where some subsets of the sample are underrepresented in the sample. $\endgroup$ May 19, 2013 at 13:42
  • $\begingroup$ Which clustering model you use? $\endgroup$
    – user31264
    Oct 17, 2013 at 4:43

1 Answer 1


Some cluster algorithms can use case weights. At least, "average" (also called UPGMA) or "Ward" clustering methods can use weights. If available, you should use those weights to get non biased results. In R, you can specify weights using the member argument of the "hclust" function (in base R). The WeightedCluster library also provides some functions (such as partionning around medoids PAM and clustering quality measure) for clustering weighted data.

You can mix different types of variable (i.e. nominal, metric, ...) using the "gower" distance. In R, this distance is available in the "cluster" library using the "daisy" function.

daisy(..., metric="gower")

You can have more information about this commands by running:


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.