Announcement

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

  • Problem Overlaying Graph Dot

    Hello,

    I'm having trouble creating a graph that overlays three dot graphs -- based on the values 1, 2, 3 held in 'grade'

    I have managed to get the following command to work:

    Code:
    graph dot (sum) val, over(issue) over(grade) scale(*.6) ytitle("Frequency") title("Frequency of adverse events over all visits", span)
    The problem with this command that works is the graph becomes very long and harder to compare the frequency of 'grades' for each 'issue'.

    Ideally, all the dots would be overlayed... with grade 1 in green, grade 2 in yellow, and grade 3 in red.

    Any help or links on how to accomplish this would be appreciated!



    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input str52 issue float grade byte valA
    "Nausea"                                               1 1
    "Reproductive system and breast disorders"             1 1
    "Diarrhoea"                                            1 1
    "Skin and subcutaneous tissue disorders"               1 1
    "Gastrointestinal disorders"                           1 1
    "Gastrointestinal disorders"                           1 1
    "Reproductive system and breast disorders"             1 1
    "Investigations"                                       1 1
    "Diarrhoea"                                            1 1
    "Blood and lymphatic system disorders"                 1 1
    "Reproductive system and breast disorders"             1 1
    "Renal and urinary disorders"                          1 1
    "Diarrhoea"                                            1 1
    "Respiratory thoracic and mediastinal disorders"       1 1
    "Investigations"                                       1 1
    "Gastrointestinal disorders"                           1 1
    "Reproductive system and breast disorders"             1 1
    "Diarrhoea"                                            1 1
    "Gastrointestinal disorders"                           1 1
    "Respiratory thoracic and mediastinal disorders"       1 1
    "General disorders and administration site conditions" 1 1
    "Reproductive system and breast disorders"             1 1
    "Renal and urinary disorders"                          1 1
    "Reproductive system and breast disorders"             1 1
    "Skin and subcutaneous tissue disorders"               1 1
    "Gastrointestinal disorders"                           1 1
    "Neutrophil count decreased"                           1 1
    "Skin and subcutaneous tissue disorders"               1 1
    "General disorders and administration site conditions" 1 1
    "Nausea"                                               1 1
    "Nausea"                                               1 1
    "Reproductive system and breast disorders"             1 1
    "Alanine aminotransferase (ALT) increased"             1 1
    "Reproductive system and breast disorders"             1 1
    "Renal and urinary disorders"                          1 1
    "General disorders and administration site conditions" 1 1
    "Skin and subcutaneous tissue disorders"               1 1
    "Renal and urinary disorders"                          1 1
    "Reproductive system and breast disorders"             1 1
    "Respiratory thoracic and mediastinal disorders"       1 1
    "Aspartate aminotransferase (AST) increased"           1 1
    "Respiratory thoracic and mediastinal disorders"       1 1
    "Aspartate aminotransferase (AST) increased"           1 1
    "Renal and urinary disorders"                          1 1
    "Respiratory thoracic and mediastinal disorders"       1 1
    "Respiratory thoracic and mediastinal disorders"       1 1
    "Skin and subcutaneous tissue disorders"               1 1
    "Platelet count decreased"                             1 1
    "Blood and lymphatic system disorders"                 1 1
    "Skin and subcutaneous tissue disorders"               1 1
    "Blood and lymphatic system disorders"                 1 1
    "Skin and subcutaneous tissue disorders"               1 1
    "General disorders and administration site conditions" 1 1
    "Skin and subcutaneous tissue disorders"               1 1
    "Blood and lymphatic system disorders"                 1 1
    "Blood and lymphatic system disorders"                 1 1
    "Respiratory thoracic and mediastinal disorders"       1 1
    "Diarrhoea"                                            1 1
    "Nausea"                                               1 1
    "Reproductive system and breast disorders"             1 1
    "Diarrhoea"                                            1 1
    "Gastrointestinal disorders"                           1 1
    "General disorders and administration site conditions" 1 1
    "General disorders and administration site conditions" 1 1
    "Reproductive system and breast disorders"             1 1
    "Alanine aminotransferase (ALT) increased"             1 1
    "Blood and lymphatic system disorders"                 1 1
    "Blood and lymphatic system disorders"                 1 1
    "Aspartate aminotransferase (AST) increased"           1 1
    "Blood and lymphatic system disorders"                 1 1
    "General disorders and administration site conditions" 1 1
    "General disorders and administration site conditions" 1 1
    "Renal and urinary disorders"                          1 1
    "Gastrointestinal disorders"                           1 1
    "Gastrointestinal disorders"                           1 1
    "Hyperglycaemia"                                       1 1
    "Reproductive system and breast disorders"             1 1
    "Respiratory thoracic and mediastinal disorders"       1 1
    "Respiratory thoracic and mediastinal disorders"       1 1
    "Neutrophil count decreased"                           1 1
    "Skin and subcutaneous tissue disorders"               1 1
    "Gastrointestinal disorders"                           1 1
    "General disorders and administration site conditions" 1 1
    "Blood and lymphatic system disorders"                 1 1
    "Skin and subcutaneous tissue disorders"               1 1
    "Reproductive system and breast disorders"             1 1
    "Skin and subcutaneous tissue disorders"               1 1
    "Blood and lymphatic system disorders"                 1 1
    "Gastrointestinal disorders"                           1 1
    "Gastrointestinal disorders"                           1 1
    "Diarrhoea"                                            1 1
    "Skin and subcutaneous tissue disorders"               1 1
    "General disorders and administration site conditions" 1 1
    "Nausea"                                               1 1
    "Blood and lymphatic system disorders"                 1 1
    "Skin and subcutaneous tissue disorders"               1 1
    "Renal and urinary disorders"                          1 1
    "Blood and lymphatic system disorders"                 1 1
    "Gastrointestinal disorders"                           1 1
    "Respiratory thoracic and mediastinal disorders"       1 1
    end
    label values grade vomiting6_
    label def vomiting6_ 1 "1", modify

  • #2
    Your example is not complete as you have just one grade level.

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input str52 issue float grade byte valA
    "Nausea"                                               1 1
    "Reproductive system and breast disorders"             1 1
    "Diarrhoea"                                            1 1
    "Skin and subcutaneous tissue disorders"               1 1
    "Gastrointestinal disorders"                           1 1
    "Gastrointestinal disorders"                           1 1
    "Reproductive system and breast disorders"             1 1
    "Investigations"                                       1 1
    "Diarrhoea"                                            1 1
    "Blood and lymphatic system disorders"                 1 1
    "Reproductive system and breast disorders"             1 1
    "Renal and urinary disorders"                          1 1
    "Diarrhoea"                                            1 1
    "Respiratory thoracic and mediastinal disorders"       1 1
    "Investigations"                                       1 1
    "Gastrointestinal disorders"                           1 1
    "Reproductive system and breast disorders"             1 1
    "Diarrhoea"                                            1 1
    "Gastrointestinal disorders"                           1 1
    "Respiratory thoracic and mediastinal disorders"       1 1
    "General disorders and administration site conditions" 1 1
    "Reproductive system and breast disorders"             1 1
    "Renal and urinary disorders"                          1 1
    "Reproductive system and breast disorders"             1 1
    "Skin and subcutaneous tissue disorders"               1 1
    "Gastrointestinal disorders"                           1 1
    "Neutrophil count decreased"                           1 1
    "Skin and subcutaneous tissue disorders"               1 1
    "General disorders and administration site conditions" 1 1
    "Nausea"                                               1 1
    "Nausea"                                               1 1
    "Reproductive system and breast disorders"             1 1
    "Alanine aminotransferase (ALT) increased"             1 1
    "Reproductive system and breast disorders"             1 1
    "Renal and urinary disorders"                          1 1
    "General disorders and administration site conditions" 1 1
    "Skin and subcutaneous tissue disorders"               1 1
    "Renal and urinary disorders"                          1 1
    "Reproductive system and breast disorders"             1 1
    "Respiratory thoracic and mediastinal disorders"       1 1
    "Aspartate aminotransferase (AST) increased"           1 1
    "Respiratory thoracic and mediastinal disorders"       1 1
    "Aspartate aminotransferase (AST) increased"           1 1
    "Renal and urinary disorders"                          1 1
    "Respiratory thoracic and mediastinal disorders"       1 1
    "Respiratory thoracic and mediastinal disorders"       1 1
    "Skin and subcutaneous tissue disorders"               1 1
    "Platelet count decreased"                             1 1
    "Blood and lymphatic system disorders"                 1 1
    "Skin and subcutaneous tissue disorders"               1 1
    "Blood and lymphatic system disorders"                 1 1
    "Skin and subcutaneous tissue disorders"               1 1
    "General disorders and administration site conditions" 1 1
    "Skin and subcutaneous tissue disorders"               1 1
    "Blood and lymphatic system disorders"                 1 1
    "Blood and lymphatic system disorders"                 1 1
    "Respiratory thoracic and mediastinal disorders"       1 1
    "Diarrhoea"                                            1 1
    "Nausea"                                               1 1
    "Reproductive system and breast disorders"             1 1
    "Diarrhoea"                                            1 1
    "Gastrointestinal disorders"                           1 1
    "General disorders and administration site conditions" 1 1
    "General disorders and administration site conditions" 1 1
    "Reproductive system and breast disorders"             1 1
    "Alanine aminotransferase (ALT) increased"             1 1
    "Blood and lymphatic system disorders"                 1 1
    "Blood and lymphatic system disorders"                 1 1
    "Aspartate aminotransferase (AST) increased"           1 1
    "Blood and lymphatic system disorders"                 1 1
    "General disorders and administration site conditions" 1 1
    "General disorders and administration site conditions" 1 1
    "Renal and urinary disorders"                          1 1
    "Gastrointestinal disorders"                           1 1
    "Gastrointestinal disorders"                           1 1
    "Hyperglycaemia"                                       1 1
    "Reproductive system and breast disorders"             1 1
    "Respiratory thoracic and mediastinal disorders"       1 1
    "Respiratory thoracic and mediastinal disorders"       1 1
    "Neutrophil count decreased"                           1 1
    "Skin and subcutaneous tissue disorders"               1 1
    "Gastrointestinal disorders"                           1 1
    "General disorders and administration site conditions" 1 1
    "Blood and lymphatic system disorders"                 1 1
    "Skin and subcutaneous tissue disorders"               1 1
    "Reproductive system and breast disorders"             1 1
    "Skin and subcutaneous tissue disorders"               1 1
    "Blood and lymphatic system disorders"                 1 1
    "Gastrointestinal disorders"                           1 1
    "Gastrointestinal disorders"                           1 1
    "Diarrhoea"                                            1 1
    "Skin and subcutaneous tissue disorders"               1 1
    "General disorders and administration site conditions" 1 1
    "Nausea"                                               1 1
    "Blood and lymphatic system disorders"                 1 1
    "Skin and subcutaneous tissue disorders"               1 1
    "Renal and urinary disorders"                          1 1
    "Blood and lymphatic system disorders"                 1 1
    "Gastrointestinal disorders"                           1 1
    "Respiratory thoracic and mediastinal disorders"       1 1
    end
    label values grade vomiting6_
    label def vomiting6_ 1 "1", modify
    
    set seed 04292022
    replace grade= runiformint(1,3)
    separate valA, by(grade) veryshortlabel
    set scheme s1color
    graph dot (sum) valA?, over(issue, sort(1)) marker(1, ms(oh)) marker(2, ms(+)) ///
    marker(3, ms(x) msize(large)) scale(*.6) ytitle("Frequency") ysc(r(-0.5 8.5)) ///
    legend(order(1 "grade 1" 2 "grade 2" 3 "grade 3") row(1))  ///
    title("Frequency of adverse events over all visits", span)
    Click image for larger version

Name:	Graph.png
Views:	1
Size:	80.4 KB
ID:	1662226

    Last edited by Andrew Musau; 29 Apr 2022, 09:37.

    Comment


    • #3
      Sorry! Didn't know it truncated 100.

      Code:
      * Example generated by -dataex-. For more info, type help dataex
      clear
      input str52 issue float grade byte val
      "Nausea"                                               1 1
      "Reproductive system and breast disorders"             1 1
      "Diarrhoea"                                            1 1
      "Skin and subcutaneous tissue disorders"               1 1
      "Gastrointestinal disorders"                           1 1
      "Gastrointestinal disorders"                           1 1
      "Reproductive system and breast disorders"             1 1
      "Investigations"                                       1 1
      "Diarrhoea"                                            1 1
      "Blood and lymphatic system disorders"                 1 1
      "Reproductive system and breast disorders"             1 1
      "Renal and urinary disorders"                          1 1
      "Diarrhoea"                                            1 1
      "Respiratory thoracic and mediastinal disorders"       1 1
      "Investigations"                                       1 1
      "Gastrointestinal disorders"                           1 1
      "Reproductive system and breast disorders"             1 1
      "Diarrhoea"                                            1 1
      "Gastrointestinal disorders"                           1 1
      "Respiratory thoracic and mediastinal disorders"       1 1
      "General disorders and administration site conditions" 1 1
      "Reproductive system and breast disorders"             1 1
      "Renal and urinary disorders"                          1 1
      "Reproductive system and breast disorders"             1 1
      "Skin and subcutaneous tissue disorders"               1 1
      "Gastrointestinal disorders"                           1 1
      "Neutrophil count decreased"                           1 1
      "Skin and subcutaneous tissue disorders"               1 1
      "General disorders and administration site conditions" 1 1
      "Nausea"                                               1 1
      "Nausea"                                               1 1
      "Reproductive system and breast disorders"             1 1
      "Alanine aminotransferase (ALT) increased"             1 1
      "Reproductive system and breast disorders"             1 1
      "Renal and urinary disorders"                          1 1
      "General disorders and administration site conditions" 1 1
      "Skin and subcutaneous tissue disorders"               1 1
      "Renal and urinary disorders"                          1 1
      "Reproductive system and breast disorders"             1 1
      "Respiratory thoracic and mediastinal disorders"       1 1
      "Aspartate aminotransferase (AST) increased"           1 1
      "Respiratory thoracic and mediastinal disorders"       1 1
      "Aspartate aminotransferase (AST) increased"           1 1
      "Renal and urinary disorders"                          1 1
      "Respiratory thoracic and mediastinal disorders"       1 1
      "Respiratory thoracic and mediastinal disorders"       1 1
      "Skin and subcutaneous tissue disorders"               1 1
      "Platelet count decreased"                             1 1
      "Blood and lymphatic system disorders"                 1 1
      "Skin and subcutaneous tissue disorders"               1 1
      "Blood and lymphatic system disorders"                 1 1
      "Skin and subcutaneous tissue disorders"               1 1
      "General disorders and administration site conditions" 1 1
      "Skin and subcutaneous tissue disorders"               1 1
      "Blood and lymphatic system disorders"                 1 1
      "Blood and lymphatic system disorders"                 1 1
      "Respiratory thoracic and mediastinal disorders"       1 1
      "Diarrhoea"                                            1 1
      "Nausea"                                               1 1
      "Reproductive system and breast disorders"             1 1
      "Diarrhoea"                                            1 1
      "Gastrointestinal disorders"                           1 1
      "General disorders and administration site conditions" 1 1
      "General disorders and administration site conditions" 1 1
      "Reproductive system and breast disorders"             1 1
      "Alanine aminotransferase (ALT) increased"             1 1
      "Blood and lymphatic system disorders"                 1 1
      "Blood and lymphatic system disorders"                 1 1
      "Aspartate aminotransferase (AST) increased"           1 1
      "Blood and lymphatic system disorders"                 1 1
      "General disorders and administration site conditions" 1 1
      "General disorders and administration site conditions" 1 1
      "Renal and urinary disorders"                          1 1
      "Gastrointestinal disorders"                           1 1
      "Gastrointestinal disorders"                           1 1
      "Hyperglycaemia"                                       1 1
      "Reproductive system and breast disorders"             1 1
      "Respiratory thoracic and mediastinal disorders"       1 1
      "Respiratory thoracic and mediastinal disorders"       1 1
      "Neutrophil count decreased"                           1 1
      "Skin and subcutaneous tissue disorders"               1 1
      "Gastrointestinal disorders"                           1 1
      "General disorders and administration site conditions" 1 1
      "Blood and lymphatic system disorders"                 1 1
      "Skin and subcutaneous tissue disorders"               1 1
      "Reproductive system and breast disorders"             1 1
      "Skin and subcutaneous tissue disorders"               1 1
      "Blood and lymphatic system disorders"                 1 1
      "Gastrointestinal disorders"                           1 1
      "Gastrointestinal disorders"                           1 1
      "Diarrhoea"                                            1 1
      "Skin and subcutaneous tissue disorders"               1 1
      "General disorders and administration site conditions" 1 1
      "Nausea"                                               1 1
      "Blood and lymphatic system disorders"                 1 1
      "Skin and subcutaneous tissue disorders"               1 1
      "Renal and urinary disorders"                          1 1
      "Blood and lymphatic system disorders"                 1 1
      "Gastrointestinal disorders"                           1 1
      "Respiratory thoracic and mediastinal disorders"       1 1
      "Respiratory thoracic and mediastinal disorders"       1 1
      "Alanine aminotransferase (ALT) increased"             1 1
      "Blood and lymphatic system disorders"                 1 1
      "Skin and subcutaneous tissue disorders"               1 1
      "Respiratory thoracic and mediastinal disorders"       1 1
      "Renal and urinary disorders"                          1 1
      "Reproductive system and breast disorders"             1 1
      "Renal and urinary disorders"                          1 1
      "Reproductive system and breast disorders"             1 1
      "Blood and lymphatic system disorders"                 1 1
      "Diarrhoea"                                            1 1
      "Skin and subcutaneous tissue disorders"               1 1
      "Gastrointestinal disorders"                           1 1
      "Respiratory thoracic and mediastinal disorders"       1 1
      "Skin and subcutaneous tissue disorders"               1 1
      "Gastrointestinal disorders"                           1 1
      "Gastrointestinal disorders"                           1 1
      "Diarrhoea"                                            1 1
      "Gastrointestinal disorders"                           1 1
      "Respiratory thoracic and mediastinal disorders"       1 1
      "Respiratory thoracic and mediastinal disorders"       1 1
      "Blood bilirubin increased"                            1 1
      "Gastrointestinal disorders"                           1 1
      "Platelet count decreased"                             1 1
      "Skin and subcutaneous tissue disorders"               1 1
      "Gastrointestinal disorders"                           1 1
      "Reproductive system and breast disorders"             1 1
      "Skin and subcutaneous tissue disorders"               1 1
      "Blood and lymphatic system disorders"                 1 1
      "Respiratory thoracic and mediastinal disorders"       1 1
      "Skin and subcutaneous tissue disorders"               1 1
      "Renal and urinary disorders"                          1 1
      "Skin and subcutaneous tissue disorders"               1 1
      "Diarrhoea"                                            1 1
      "Mucositis oral"                                       1 1
      "Blood and lymphatic system disorders"                 1 1
      "Gastrointestinal disorders"                           1 1
      "Reproductive system and breast disorders"             1 1
      "Reproductive system and breast disorders"             1 1
      "Blood and lymphatic system disorders"                 1 1
      "Reproductive system and breast disorders"             1 1
      "Reproductive system and breast disorders"             1 1
      "Respiratory thoracic and mediastinal disorders"       1 1
      "Renal and urinary disorders"                          1 1
      "Gastrointestinal disorders"                           1 1
      "Platelet count decreased"                             1 1
      "General disorders and administration site conditions" 1 1
      "Nausea"                                               1 1
      "Investigations"                                       1 1
      "Investigations"                                       2 1
      "Respiratory thoracic and mediastinal disorders"       2 1
      "Reproductive system and breast disorders"             2 1
      "Renal and urinary disorders"                          2 1
      "Respiratory thoracic and mediastinal disorders"       2 1
      "Skin and subcutaneous tissue disorders"               2 1
      "Skin and subcutaneous tissue disorders"               2 1
      "General disorders and administration site conditions" 2 1
      "Skin and subcutaneous tissue disorders"               2 1
      "Blood and lymphatic system disorders"                 2 1
      "Skin and subcutaneous tissue disorders"               2 1
      "Gastrointestinal disorders"                           2 1
      "Gastrointestinal disorders"                           2 1
      "Reproductive system and breast disorders"             2 1
      "Blood and lymphatic system disorders"                 2 1
      "Reproductive system and breast disorders"             2 1
      "Gastrointestinal disorders"                           2 1
      "Skin and subcutaneous tissue disorders"               2 1
      "Reproductive system and breast disorders"             2 1
      "General disorders and administration site conditions" 2 1
      "Gastrointestinal disorders"                           2 1
      "Gastrointestinal disorders"                           2 1
      "Reproductive system and breast disorders"             2 1
      "General disorders and administration site conditions" 2 1
      "Gastrointestinal disorders"                           2 1
      "Respiratory thoracic and mediastinal disorders"       2 1
      "Gastrointestinal disorders"                           2 1
      "Respiratory thoracic and mediastinal disorders"       2 1
      "Blood and lymphatic system disorders"                 2 1
      "Reproductive system and breast disorders"             2 1
      "Skin and subcutaneous tissue disorders"               2 1
      "Skin and subcutaneous tissue disorders"               2 1
      "Investigations"                                       2 1
      "Reproductive system and breast disorders"             2 1
      "Skin and subcutaneous tissue disorders"               2 1
      "Skin and subcutaneous tissue disorders"               2 1
      "Gastrointestinal disorders"                           2 1
      "Reproductive system and breast disorders"             2 1
      "Skin and subcutaneous tissue disorders"               2 1
      "Reproductive system and breast disorders"             2 1
      "Renal and urinary disorders"                          2 1
      "Skin and subcutaneous tissue disorders"               2 1
      "Gastrointestinal disorders"                           2 1
      "Renal and urinary disorders"                          2 1
      "Gastrointestinal disorders"                           2 1
      "Skin and subcutaneous tissue disorders"               2 1
      "Reproductive system and breast disorders"             2 1
      "Gastrointestinal disorders"                           2 1
      "Respiratory thoracic and mediastinal disorders"       2 1
      "Blood and lymphatic system disorders"                 2 1
      "Reproductive system and breast disorders"             2 1
      "Gastrointestinal disorders"                           2 1
      "Blood and lymphatic system disorders"                 2 1
      "Reproductive system and breast disorders"             2 1
      "Skin and subcutaneous tissue disorders"               3 1
      "Gastrointestinal disorders"                           3 1
      "Reproductive system and breast disorders"             3 1
      end
      label values grade vomiting6_
      label def vomiting6_ 1 "1", modify
      label def vomiting6_ 2 "2", modify
      label def vomiting6_ 3 "3", modify

      Comment


      • #4
        That's great Andrew! Works awesome! Thanks

        Comment


        • #5
          Here's another take using the data example from #3. There must be a better order than alphabetical. Lacking any clinical expertise I sorted on mean grade and frequencies of mentions. "Investigations" may well be professional jargon for "Something else I can't pin down" or "I can't understand my own notes".


          Code:
          egen mean = mean(grade), by(issue)
          egen count1 = total(grade==1), by(issue)
          egen count2 = total(grade==2), by(issue)
          egen ISSUE = group(mean count1 count2  issue)
          * labmask and tabplot are from the Stata Journal 
          labmask ISSUE, values(issue)
          tabplot ISSUE grade , ysc(reverse) showval(offset(-0.5)) horizontal ytitle("") xsc(alt) separate(grade) bar3(color(red)) bar2(fcolor(red*0.4) lcolor(red)) bar1(color(blue)) subtitle("") xsc(r(0.8 .)) height(0.75) yla(, labsize(small))
          There is surely scope to remove uninformative words such as "disorders".

          Click image for larger version

Name:	rahnen.png
Views:	1
Size:	40.0 KB
ID:	1662256

          Comment

          Working...
          X