# Data visualisation for binary response data

I'm seeking alternative ways of representing my data.

I have conducted an experiment, with two manipulated variables (v1 from 0 to 3, v2 from -3 to 0), and by factorial design it yields 4*4=16 stimuli. Participants give a 0/1 response for each stimulus. So for each individual I have a following response matrix (Table 1). After I collected data from multiple individuals, I can calculate the percentage of "1" response for each stimuli, leading to a summary results for all individuals (Table 2).

Participants are recruited from two countries. So there are two groups of people. They faced the same stimuli. My ultimate goal is to compare the different response pattern between the two groups.

Table 1. Individual response matrix
+-----+---+----+----+----+
|v1/v2| 0 | -1 | -2 | -3 |
+-----+---+----+----+----+
| 0   | 0 | 0  | 1  | 0  |
+-----+---+----+----+----+
| 1   | 0 | 0  | 1  | 0  |
+-----+---+----+----+----+
| 2   | 0 | 0  | 1  | 1  |
+-----+---+----+----+----+
| 3   | 0 | 1  | 1  | 1  |
+-----+---+----+----+----+

Table 2. Summary results (percentage of "1" responses)
+-----+---+----+----+----+
|v1/v2| 0 | -1 | -2 | -3 |
+-----+---+----+----+----+
| 0   |20%| 39%| 45%| 50%|
+-----+---+----+----+----+
| 1   |34%| 53%| 78%| 78%|
+-----+---+----+----+----+
| 2   |43%| 85%| 95%| 99%|
+-----+---+----+----+----+
| 3   |80%| 86%|100%|100%|
+-----+---+----+----+----+


In my story, v1-v2 is always a crucial predictor. For one group of participants, the absolute v2/v1 is also a crucial predictor. For another group, only v1-v2 matters. The idealised pattern is like follows:

My colleagues found these figures not very intuitive. So I'm seeking alternative ways of presenting the data. Here is some thoughts I have, but not entirely sure how to achieve this.

1. I'm thinking of a more 'direct' way of translating the summary table into graphs, like colormap (not sure if this is the right name). In this way I could use v1 and v2 as two axis (instead of v1-v2), and marking the value through color. Is this implementable in R?

2. Another way of revising my current figure is that, I keep using v1-v2 as x-axis, but not using v2 as grouping variable, but show the variance at each v1-v2 level, which also helps distinguish the two groups.

3. For individual responses (Table 1) there seems to be a boundary line that divides 0 and 1 (downright more likely to be 1, and upleft more likely to be 0), and this boundary line may be different for each individuals. The summary data loses this information on individuals. I wonder if I could estimate a boundary line for each individual (like a regression), and compare the distribution of this boundary line between two groups.

Or if you have other thoughts in presenting the data, I'll appreciate your help!

• May be a 3D plot is your solution? v1 is x-axis, v2 is y-axis, and the entries of table 2 are heights on the z-axis.
– Nick
Nov 9, 2019 at 20:46

Regarding question 1, here an example with your data implemented in R:

library(tidyverse)

df = data.frame(v1 = c(rep(c(0,-1,-2,-3),4)), v2 = c(rep(0,4), rep(1,4), rep(2,4), rep(3,4)),
percentage = c(20, 39, 45, 50, 34, 53, 78, 78, 43, 85, 95, 99, 80, 86, 100, 100) )

p = ggplot(df)
p = p + geom_raster(aes(x = v1, y = v2, fill = percentage))
p = p + scale_fill_gradient(low = "#56B1F7", high = "#132B43")
p = print(p)


• Thanks! It is probably the best I could get! Dec 9, 2019 at 12:42