Announcement

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

  • SPIDER: Stata module for spider plots (radar plot)

    Dear Statalist community,

    Currently I am trying to perform a Spider plot with the package spider, using Stata 18.

    I was trying to follow up the tutorial that Asjad Naqvi kindly provide in GitHub:

    GitHub - asjadnaqvi/stata-spider: spider: A Stata package for spider plots.

    But unfortunately, the by() option is not allowed when I try to perform the code


    Code:
    spider Domain_score , over ( Domain_name ) by ( EQIndex_detoriation)
    option by() not allowed
    r(198);



    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input float subject_id byte Domain_score str1 Domain_moment_BorF byte EQIndex_detoriation str19 Domain_name
    6184 2 "b" 1 "Mobility"      
    6184 1 "b" 1 "Selfcare"      
    6184 2 "b" 1 "DailyActivities"
    6184 1 "b" 1 "PainDiscomfort"
    6184 1 "b" 1 "FearDepressed"  
    6184 3 "f" 1 "Mobility"      
    6184 1 "f" 1 "Selfcare"      
    6184 4 "f" 1 "DailyActivities"
    6184 3 "f" 1 "PainDiscomfort"
    6184 2 "f" 1 "FearDepressed"  
    5926 1 "b" 1 "Mobility"      
    5926 1 "b" 1 "Selfcare"      
    5926 1 "b" 1 "DailyActivities"
    5926 1 "b" 1 "PainDiscomfort"
    5926 1 "b" 1 "FearDepressed"  
    5926 1 "f" 1 "Mobility"      
    5926 2 "f" 1 "Selfcare"      
    5926 2 "f" 1 "DailyActivities"
    5926 2 "f" 1 "PainDiscomfort"
    5926 1 "f" 1 "FearDepressed"  
    5800 1 "b" 1 "Mobility"      
    5800 1 "b" 1 "Selfcare"      
    5800 2 "b" 1 "DailyActivities"
    5800 1 "b" 1 "PainDiscomfort"
    5800 2 "b" 1 "FearDepressed"  
    5800 2 "f" 1 "Mobility"      
    5800 2 "f" 1 "Selfcare"      
    5800 3 "f" 1 "DailyActivities"
    5800 1 "f" 1 "PainDiscomfort"
    5800 1 "f" 1 "FearDepressed"  
    5731 1 "b" 1 "Mobility"      
    5731 1 "b" 1 "Selfcare"      
    5731 1 "b" 1 "DailyActivities"
    5731 2 "b" 1 "PainDiscomfort"
    5731 2 "b" 1 "FearDepressed"  
    5731 1 "f" 1 "Mobility"      
    5731 3 "f" 1 "Selfcare"      
    5731 4 "f" 1 "DailyActivities"
    5731 3 "f" 1 "PainDiscomfort"
    5731 4 "f" 1 "FearDepressed"  
    5690 5 "b" 1 "Mobility"      
    5690 5 "b" 1 "Selfcare"      
    5690 1 "b" 1 "DailyActivities"
    5690 4 "b" 1 "PainDiscomfort"
    5690 2 "b" 1 "FearDepressed"  
    5690 5 "f" 1 "Mobility"      
    5690 5 "f" 1 "Selfcare"      
    5690 3 "f" 1 "DailyActivities"
    5690 4 "f" 1 "PainDiscomfort"
    5690 1 "f" 1 "FearDepressed"  
    5644 1 "b" 1 "Mobility"      
    5644 1 "b" 1 "Selfcare"      
    5644 1 "b" 1 "DailyActivities"
    5644 3 "b" 1 "PainDiscomfort"
    5644 2 "b" 1 "FearDepressed"  
    5644 3 "f" 1 "Mobility"      
    5644 1 "f" 1 "Selfcare"      
    5644 3 "f" 1 "DailyActivities"
    5644 1 "f" 1 "PainDiscomfort"
    5644 2 "f" 1 "FearDepressed"  
    5474 1 "b" 1 "Mobility"      
    5474 1 "b" 1 "Selfcare"      
    5474 1 "b" 1 "DailyActivities"
    5474 3 "b" 1 "PainDiscomfort"
    5474 1 "b" 1 "FearDepressed"  
    5474 3 "f" 1 "Mobility"      
    5474 1 "f" 1 "Selfcare"      
    5474 3 "f" 1 "DailyActivities"
    5474 3 "f" 1 "PainDiscomfort"
    5474 2 "f" 1 "FearDepressed"  
    5466 2 "b" 1 "Mobility"      
    5466 2 "b" 1 "Selfcare"      
    5466 1 "b" 1 "DailyActivities"
    5466 1 "b" 1 "PainDiscomfort"
    5466 1 "b" 1 "FearDepressed"  
    5466 1 "f" 1 "Mobility"      
    5466 1 "f" 1 "Selfcare"      
    5466 2 "f" 1 "DailyActivities"
    5466 2 "f" 1 "PainDiscomfort"
    5466 1 "f" 1 "FearDepressed"  
    5394 1 "b" 1 "Mobility"      
    5394 1 "b" 1 "Selfcare"      
    5394 1 "b" 1 "DailyActivities"
    5394 1 "b" 1 "PainDiscomfort"
    5394 1 "b" 1 "FearDepressed"  
    5394 5 "f" 1 "Mobility"      
    5394 1 "f" 1 "Selfcare"      
    5394 5 "f" 1 "DailyActivities"
    5394 1 "f" 1 "PainDiscomfort"
    5394 1 "f" 1 "FearDepressed"  
    5300 1 "b" 1 "Mobility"      
    5300 1 "b" 1 "Selfcare"      
    5300 1 "b" 1 "DailyActivities"
    5300 1 "b" 1 "PainDiscomfort"
    5300 1 "b" 1 "FearDepressed"  
    5300 2 "f" 1 "Mobility"      
    5300 1 "f" 1 "Selfcare"      
    5300 2 "f" 1 "DailyActivities"
    5300 2 "f" 1 "PainDiscomfort"
    5300 1 "f" 1 "FearDepressed"  
    end




    I also have a second issue, and not sure how to solve it:
    The labels in the radar are quite weird (1-2-2-2-2 instead of 0-1-2-3-4-5), and I can't edit them in the edition window


    Click image for larger version

Name:	exampleradar.png
Views:	1
Size:	91.9 KB
ID:	1752518






    Thanks in advance for your help!






    Last edited by Carolina Hincapie; 07 May 2024, 06:01.

  • #2
    Asjad Naqvi is a member here and might respond to pinging. He last was here on 1 March. My impression is that he hangs out much more on GitHub, Medium or Twitter.

    I have never used spider, but I note from its help on SSC this request

    Code:
    Feedback
    
    Please submit bugs, errors, feature requests on GitHub by opening a new issue.
    For showing means of several such variables, I would tend to use graph dot or graph hbar.

    Comment


    • #3
      Thanks a lot Nick Cox !

      I posted at the same time the request on GitHub, and indeed he already saw it there, not reply yet.

      @asjadnaqvi asjadnaqvi self-assigned this 12 minutes ago
      @asjadnaqvi asjadnaqvi added the bug label 12 minutes ago
      @asjadnaqvi asjadnaqvi added this to StataViz issue tracker 12 minutes ago

      Comment


      • #4
        Something like

        Code:
        graph hbar Domain_score , over(Domain_name) by(EQIndex_detoriation)
        might help.

        If you want further command advice to explore that, then post the means


        Code:
        collapse Domain_score, by(Domain_name EQIndex_detoriation)
        
        dataex

        Picky detail: For your paper/report./thesis, use the spelling deterioration.

        Comment


        • #5
          Dear Nick Cox , thank again!



          Code:
          ****NoDet-Baseline****
          
          tab Domain_name if EQIndex_det==0 & Domain_moment_BorF=="b" , sum ( Domain_score )
          
                             |       Summary of Domain_score
                 Domain_name |        Mean   Std. dev.       Freq.
          -------------------+------------------------------------
             DailyActivities |   2.9071038   1.4013745         183
               FearDepressed |   1.7650273   .95760741         183
                    Mobility |   2.6448087   1.2879675         183
              PainDiscomfort |    2.557377   1.1653126         183
                    Selfcare |   2.0218579    1.338181         183
          -------------------+------------------------------------
                       Total |    2.379235   1.3070276         915
          
          
          ****Det-Baseline****
          
          . tab Domain_name if EQIndex_det==1 & Domain_moment_BorF=="b" , sum ( Domain_score )
          
                             |       Summary of Domain_score
                 Domain_name |        Mean   Std. dev.       Freq.
          -------------------+------------------------------------
             DailyActivities |   2.0754717   1.1355562         106
               FearDepressed |   1.4622642   .77058454         106
                    Mobility |   2.2924528   1.2186408         106
              PainDiscomfort |   1.9245283    .9729495         106
                    Selfcare |   1.6509434   1.1384405         106
          -------------------+------------------------------------
                       Total |   1.8811321   1.0960587         530
          
          
          
          ****NoDet-F/U****
          
          . tab Domain_name if EQIndex_det==0 & Domain_moment_BorF=="f" , sum ( Domain_score )
          
                             |       Summary of Domain_score
                 Domain_name |        Mean   Std. dev.       Freq.
          -------------------+------------------------------------
             DailyActivities |   2.3114754    1.273668         183
               FearDepressed |   1.4918033   .78354543         183
                    Mobility |   2.2622951   1.2740216         183
              PainDiscomfort |   1.9945355   .98615285         183
                    Selfcare |   1.7103825   1.1851885         183
          -------------------+------------------------------------
                       Total |   1.9540984   1.1582036         915
          
          
          
          ****Det-F/U****
          
          . tab Domain_name if EQIndex_det==1 & Domain_moment_BorF=="f" , sum ( Domain_score )
          
                             |       Summary of Domain_score
                 Domain_name |        Mean   Std. dev.       Freq.
          -------------------+------------------------------------
             DailyActivities |   3.1037736   1.2105036         106
               FearDepressed |   1.9622642   .99450422         106
                    Mobility |   2.8018868   1.1663522         106
              PainDiscomfort |   2.5943396   1.1692757         106
                    Selfcare |   1.9622642   1.3087583         106
          -------------------+------------------------------------
                       Total |   2.4849057   1.2558967         530

          Comment


          • #6
            That's not quite what I asked for but with some (a lot of) editing it can be made into a dataset. There is massive scope to display the results in different ways depending on what you most want to compare.

            Code:
            * Example generated by -dataex-. For more info, type help dataex
            clear
            input str20 Domain_name float EQ str1 borf double(mean SD) int freq
            "DailyActivities" 0 "b" 2.9071038 1.4013745 183
            "FearDepressed"   0 "b" 1.7650273 .95760741 183
            "Mobility"        0 "b" 2.6448087 1.2879675 183
            "PainDiscomfort"  0 "b"  2.557377 1.1653126 183
            "Selfcare"        0 "b" 2.0218579  1.338181 183
            "DailyActivities" 1 "b" 2.0754717 1.1355562 106
            "FearDepressed"   1 "b" 1.4622642 .77058454 106
            "Mobility"        1 "b" 2.2924528 1.2186408 106
            "PainDiscomfort"  1 "b" 1.9245283  .9729495 106
            "Selfcare"        1 "b" 1.6509434 1.1384405 106
            "DailyActivities" 0 "f" 2.3114754  1.273668 183
            "FearDepressed"   0 "f" 1.4918033 .78354543 183
            "Mobility"        0 "f" 2.2622951 1.2740216 183
            "PainDiscomfort"  0 "f" 1.9945355 .98615285 183
            "Selfcare"        0 "f" 1.7103825 1.1851885 183
            "DailyActivities" 1 "f" 3.1037736 1.2105036 106
            "FearDepressed"   1 "f" 1.9622642 .99450422 106
            "Mobility"        1 "f" 2.8018868 1.1663522 106
            "PainDiscomfort"  1 "f" 2.5943396 1.1692757 106
            "Selfcare"        1 "f" 1.9622642 1.3087583 106
            end
            
            label def EQ 0 "EQ = 0" 1 "EQ = 1"
            label val EQ EQ 
            
            foreach x in Activities Depressed Discomfort { 
                replace Domain_name = subinstr(Domain_name, "`x'", " `x'", 1)
            }
            
            graph dot (asis) mean , asyvars over(borf) over(Domain_name) marker(1, ms(Oh)) marker(2, ms(Th)) ///
            by(EQ, col(1) note("") legend(pos(3)) b1title(Mean score)) subtitle(, pos(12) nobox) exclude0 yla(1(0.5)3)  legend(col(1))
            Click image for larger version

Name:	domain.png
Views:	1
Size:	40.7 KB
ID:	1752716

            Comment


            • #7
              Nick Cox really thanks a looot!!!

              Comment


              • #8
                A further refinement is to move away from alphabetical order. Here I use myaxis from the Stata Journal. https://journals.sagepub.com/doi/pdf...6867X211045582


                Code:
                egen Domain_name2 = group(Domain_name), label 
                
                myaxis axis=Domain_name, sort(mean mean)
                
                graph dot (asis) mean , asyvars over(borf) over(axis) marker(1, ms(Oh)) marker(2, ms(Th)) ///
                by(EQ, col(1) note("") legend(pos(3)) b1title(Mean score)) subtitle(, nobox pos(9) orient(vertical)) exclude0 yla(1(0.5)3)  legend(col(1))
                Click image for larger version

Name:	eq.png
Views:	1
Size:	54.3 KB
ID:	1752799

                Comment


                • #9
                  Dear Carolina Hincapie (and Nick Cox thanks for the ping!)

                  I already responded on GitHub but general notes for the community:
                  spider has bee updated to v1.31 to add additional checks to avoid data issues with three major changes:
                  • Checks added for by() and over() to have a minimum number of categories (3 and 2 respectively).
                  • Changed raformat() to just format(), a more standard use.
                  • format() now shows decimals by default
                  Please install directly from GitHub for now till the package gets updated on SSC.


                  Syntax for the graph below:
                  Code:
                  spider Domain_score, by(Domain_name) over(Domain_moment_BorF) format(%5.2f) smooth(0.5)

                  Click image for larger version

Name:	spider2.png
Views:	1
Size:	263.8 KB
ID:	1753013

                  Comment


                  • #10
                    Dear Asjad Naqvi thanks a lot!!

                    Comment

                    Working...
                    X