Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Trouble with select option in upsetplot

    Hi everyone, thanks in advance for any help.

    I have a dataset of reproductive-aged women that includes information about reasons why they are not using contraception. Respondents could choose as many reasons as they liked from a list of 21 reasons ("I'm worried about side effects," "I don't have frequent sex," "I had a hysterectomy," etc.). I'm using Tim Morris and Nick Cox's excellent upsetplot in Stata 18 to graph the frequencies of each set of responses. I'd like to show just the, say, top 10 most frequent sets, but I'm having trouble with the select option. I can't share the dataset but I've reproduced the problem below.

    Code:
    clear
    input Rice Maize Sorghum Arabidopsis freq
    1 0 0 0 1110
    1 1 0 0 229
    0 1 0 0 465
    1 0 1 0 661
    1 1 1 0 2077
    0 1 1 0 405
    0 0 1 0 265
    1 0 1 1 304
    1 1 1 1 8494
    0 1 1 1 112
    0 0 1 1 34
    1 0 0 1 81
    1 1 0 1 96
    0 1 0 1 11
    0 0 0 1 1058
    end
    
    label var Arabidopsis "{it:Arabidopsis}"
    local toptitle  "t1title(Number of gene families)"
    
    upsetplot A R M S [fw=freq], varlabels  baropts(`toptitle' `bcolour')
    Click image for larger version

Name:	graph1.png
Views:	1
Size:	179.3 KB
ID:	1766266

    As we can see above, the three most common combinations have frequencies of 8494, 2077, and 1110. However, when I include select(1/3), I get the 6th, 7th, and 9th bars, not the first three as expected.

    Code:
    upsetplot A R M S [fw=freq], varlabels  baropts(`toptitle' `bcolour') select(1/3)
    Click image for larger version

Name:	graph2.png
Views:	1
Size:	138.1 KB
ID:	1766264

    Am I misunderstanding the select option? Is something else going on? Any help is appreciated!
Working...
X