Title: Two categorical variables
Course: UGQuants (SSPS) > Section: Data Visualisation

Two categorical variables

Where the two variables under consideration are both categorical, a “heat map” can be seen as providing visual equivalent of a cross-tabulation.  In a heat map, the “explanatory” variable is placed on the x-axis of the graph, with the dependent variable placed on the y-axis.  Assuming both variables are categorical, this creates a grid. The cells within this grid can then be shaded to represent the frequency with which they are present in the data (see figure 23).

Typically, less common combinations are shaded lightly, while cells with greater frequency are darker in appearance.  Such an analysis provides an intuitive representation of the presence of different combinations of the two variables within the data.  However, while this may provide a good overview of any relationship, it is not possible to read off specific percentages or frequencies as it is with a cross-tabulation.

In our example, we have formed five groups of CO2 emitters, based on the quintiles of the continuous CO2 variable.

Figure 23: heatmap of CO2 emissions by world region

Source: ESS 2010 (UK).

The above heat map is based on the prevalence of each combination within the sample as a whole.  This is the equivalent of a cross-tabulation presenting “total” cell percentages.  This helps to identify the most popular combinations of outcomes across the two variables.  In this case, it also provides a general overview of the relationship between the region in which a country lies and its CO2 emissions – Sub-Saharan African countries emit little CO2, while the countries of other regions show a bigger variation in their CO2 emissions.  However, the clarity of this finding is dependent on having a reasonably equal number of respondents in each group.  If one region had only a small number of countries in it (such as the Middle East & North Africa), then all the cells for that group would be lightly shaded compared to the rest of the heat map, and any relationship with CO2 emissions would not be visible.

Rather than basing the shading of cells on the prevalence of a given combination of values within the sample as a whole, some software packages allow you to change this to reflect prevalence within each category on one of the variables under consideration, This is the equivalent of using row or column percentages in a cross-tabulation.

Figure 24: heatmap of CO2 emissions by world region adjusted for number of countries in region

Source: ESS 2010 (UK).