Vian
Vian

Reputation: 1

How to solve 'Impossible: negative area' error message when trying to generate a 5 way Venn?

I have not used this function in R before. I want a Venn to represent papers in a review I am doing to reflect the different concepts I have identified, some individual papers can show more than one concept. I calculated the number of times papers exhibit more than two and therefore overlap. I keep getting the same error message stating that some areas of in the negative, but I don't really understand why, can anyone help. I have looked at the R pdf for this function, but can't seem to work out what I am doing wrong. Thanks in advance

 venn.plot <- draw.quintuple.venn(
area1 = 29,
area2 = 26,
area3 = 41,
area4 = 22,
area5 = 10,
n12 = 2,
n13 = 3,
n14 = 3,
n15 = 1,
n23 = 2,
n24 = 1,
n25 = 1,
n34 = 4,
n35 = 1,
n45 = 0, 
n123 = 5,
n124 = 1,
n125 = 1,
n134 = 2,
n135 = 1,
n145 = 0,
n234 = 3,
n235 = 0,
n245 = 0,
n345 = 0, 
n1234 = 1,
n1235 = 4,
n1245 = 0,
n1345 = 0,
n2345 = 3,
n12345 =1, 
category = c("A", "B", "C", "D", "E"),
fill = c("dodgerblue", "goldenrod1", "darkorange1", "seagreen3", "orchid3"),
cat.col = c("dodgerblue", "goldenrod1", "darkorange1", "seagreen3", "orchid3"),
ind = TRUE
)

Upvotes: 0

Views: 245

Answers (1)

user2554330
user2554330

Reputation: 44887

The message you get is

ERROR [2019-11-27 05:56:26] Impossible: a9 <- n12 - a19 - a20 - a22 - a28 - a29 - a30 - a31 produces negative area
Error in draw.quintuple.venn(area1 = 29, area2 = 26, area3 = 41, area4 = 22,  : 
  Impossible: a9 <- n12 - a19 - a20 - a22 - a28 - a29 - a30 - a31 produces negative area

While normally it's a good idea to report error messages when you are asking about them, this particular error message isn't all that informative unless you look at the source to the function. That has this series of calculations:

    a31 <- n12345
    a30 <- n1234 - a31
    a29 <- n1235 - a31
    a28 <- n1245 - a31
    a27 <- n1345 - a31
    a26 <- n2345 - a31
    a25 <- n245 - a26 - a28 - a31
    a24 <- n234 - a26 - a30 - a31
    a23 <- n134 - a27 - a30 - a31
    a22 <- n123 - a29 - a30 - a31
    a21 <- n235 - a26 - a29 - a31
    a20 <- n125 - a28 - a29 - a31
    a19 <- n124 - a28 - a30 - a31
    a18 <- n145 - a27 - a28 - a31
    a17 <- n135 - a27 - a29 - a31
    a16 <- n345 - a26 - a27 - a31
    a15 <- n45 - a18 - a25 - a16 - a28 - a27 - a26 - a31
    a14 <- n24 - a19 - a24 - a25 - a30 - a28 - a26 - a31
    a13 <- n34 - a16 - a23 - a24 - a26 - a27 - a30 - a31
    a12 <- n13 - a17 - a22 - a23 - a27 - a29 - a30 - a31
    a11 <- n23 - a21 - a22 - a24 - a26 - a29 - a30 - a31
    a10 <- n25 - a20 - a21 - a25 - a26 - a28 - a29 - a31
    a9 <- n12 - a19 - a20 - a22 - a28 - a29 - a30 - a31

After a bit of work, a9 simplifies to

a9 <- n12 - n124  - n125 - n123 + n1245 + n1235  + n1234 - n12345

i.e. it's the total count in class 1 and 2 that are not in class 3, 4, or 5. From the numbers you entered, this is

2 - 1 - 1 - 5 + 0 + 4 + 1 - 1 = -1

which is impossible. So you've got an error in your input data.

Upvotes: 1

Related Questions