I am not a statistician, so please excuse my lack of statistics knowledge/terminology.

I have bunch of network nodes that I want to run cluster analysis on and identify clusters. So as far as I understand, I can follow the following steps to run a hierarchical agglomerative analysis (HAC):

  1. Identify variables
  2. Define a distance function
  3. Run the algorithm to join closer clusters and create one big cluster
  4. Cut the dendrogram tree at the height that makes meaningful clusters based on context

My question is related to the second step even though it is not yet clear for me how I am going to do the last step.

The data I want to analyse is bunch of computer network nodes which are down (not responding). I have the following information for each network node:

  • location (longitude, latitude)
  • time node went down
  • network provider

These are the most relevant information I believe I have to take into consideration for my clustering. Basically I want to cluster the nodes that went down probably because of the same reason in a region.

For example if bunch of nodes went down at about the same time and physically they are close to each other and they have the same provider, so probably they fall into the same cluster.

Now the question is how do I derive my distance function and include all these variables in it such that it would make sense? In other words what is the mechanism to derive a distance function based on multiple variables?

Also as you notice the variables are of different types. So, in the distance function should I take care of this by considering Gower's coefficient of similarity? How?

Any examples or suggestion regarding whether I am in the right direction or not can be very helpful too.


2 Answers 2


Latitude and longitude are scale variables. Time is scale, too (I hope it is linear, not cyclic). Provider is nominal variable. I see two options:

  • Use Two-step cluster analysis. This is the method of choice if you have many (thousands) of objects (nodes) to cluster. This method has a nice option to detect outliers automatically; aside from this it is quite coarse method.
  • Use Hierarchical cluster analysis basing it on Gower coefficient (look here for links where you could compute it). This clustering is appropriate if the number of objects is, say, up to 500. You should choose among several agglomeration methods. With Gower coefficient, since it is not euclidean/metric, only average, single, complete methods should be considered consistent (but not Ward or centroid or median). You probably choose between average and complete (or try both), for single produces too oblong clusters.

There exist, of course, other clustering methods potentially apropriate (for example, a modification of K-Means that can take nominal variables), but I haven't use them, so can't recommend.

A good way to decide on the proper number of clusters is to use some internal clustering criterion, such as Silhouette statistic, cophenetic correlation, BIC, etc. (if you use SPSS, find macros to compute them on my web-page). In clustering, you produce and save a range of cluster solutions (say, from 20-cluster solution to 2-cluster solution) which are variables of cluster membership, and then check by one or more clustering criterions which of the solutions represent the most well-separated clusters - ideal solution is when density inside clusters is high and between them is low.

  • $\begingroup$ Tnx. But I am not using SPSS or any stat. software. I am going to choose the suitable method and implement the algorithm in a programming language. The question is how you write the distance function when you have multiple variables of different types? Like how do you implement Gower's coefficient in your distance function? $\endgroup$
    – kaptan
    Nov 29, 2011 at 2:05
  • $\begingroup$ You want to know formulas how Gower is computed? By my link above there you find some links to papers in english that provide it. The description for my macro also give it, but it's in russian. $\endgroup$
    – ttnphns
    Nov 29, 2011 at 7:59
  • $\begingroup$ On a second thought, I may just use R to take care of the clustering (to avoid reinventing the wheel.) I posted a new question [gis.stackexchange.com/questions/17638/… which is more about how the spatial cluster analysis can be done in R. Do you know about useful packages in R for spatial cluster analysis? tnx. $\endgroup$
    – kaptan
    Dec 6, 2011 at 23:59

For the geographic distances, it will make sense to combine latitude and longitude into a single quantity. A formula from this page should help:


where code is given to compute distance along the surface of the Earth, rounded to the nearest kilometer. You will probably want to leave out the rounding.

Then combine distance with the other quantities.


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.