I have a 10x10 matrix composed of two variables with 10 brands each. One variable is the brand purchased, the other is the brand considered. My matrix shows a crosstabulation between the two. I need an effective way to clearly visualize these data so that proximities suggest similarities between categories and distances dissimilarities. I ran a correspondence analysis, but wasn't impressed with the graph. Are there any alternative technique to consider?

  • 2
    $\begingroup$ Can you say more about what was wrong / inadequate about the correspondence analysis? $\endgroup$ Apr 12 '13 at 4:50
  • $\begingroup$ So the data are basically pairs of [brand considered, brand chosen]? If so then your crosstab is a transition matrix. That characterisation might help you find a nice visualisation. $\endgroup$ Apr 13 '13 at 16:57
  • $\begingroup$ Following that line of thought you might look at how people visualise mobility tables in sociology (correspondence analysis and also 'association models' spring immediately to mind) $\endgroup$ Apr 13 '13 at 16:57

I'm not certain of your exact data, or the process you're using to analyze it, but what you describe makes me think of a correlation matrix. In R, generating the matrix, as well as the corresponding heat map (with dendrogram) is easy. The example below used example data to show correlations between usage rates of different IT applications, and generates the image using the "plots" and "RColorBrewer" packages in R.

Note that you do not need to pass a correlation matrix to the following script example; you may pass cross-tab results directly, as any numbers in the matrix will be translated into the heatmap.

Sample data:

,Service Catalog, Incident Management, CMDB, Platform, Change Management, Knowledge, 
    Request Management
Service Catalog,100,95,92,88,85,80,65
Incident Management,95,100,90,79,86,83,50
Change Management,85,86,85,79,100,58,85
Request Management,65,50,42,45,85,45,100

Sample code:

MyData <- subset(Example, select=c(Service.Catalog:Request.Management))

MyMatrix <- as.matrix(MyData)
MyScaled <- scale(MyMatrix)



png(filename="MyTest.png", width = 500, height = 500, res=72)

heatmap.2(MyMatrix, margins=c(20,20))

heatmap(MyMatrix, margins=c(15,15))

Example image

  • $\begingroup$ Is that a correlation matrix? The OP clearly asked to visualize a crosstabulation. I believe, though, theat map like yours is possible with it, too. The colours will tell of the cell residuals. $\endgroup$
    – ttnphns
    Apr 12 '13 at 10:15
  • $\begingroup$ The sample code provided does not require the input data be the result of a correlation matrix analysis, so any numerical data (e.g. averages, percentages, etc) will work. $\endgroup$ Apr 12 '13 at 12:35
  • $\begingroup$ The key here to this display is to order the columns/rows so that not only is color useful in depicting whatever value (perhaps residuals as ttnphns mentions), but also that similar items are nearby in rows and columns. I presume a logical ordering can be derived from the correspondence analysis itself (although here it looks like the heatmap function has some default ordering not explicit in the code, but kind of identifiable from the attached hierarchical clustering dendrograms). $\endgroup$
    – Andy W
    Apr 12 '13 at 13:57

A two-way bar chart is often as effective as anything else. You have in effect a table of bars arranged in rows and columns. Length or height of bar encodes count or amount in cell, rather than colour of tile in a heat map.

The same kind of display comes under many names, including aligned bar charts, multi-pane bar charts, survey plots, table lens, Bertin plots, Hinton plots, Willshaw plots, and no doubt others.

A correspondence analysis can indicate good ordering of rows and columns; this problem is often called seriation.

See for example http://www.jstatsoft.org/v25/i03


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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