Announcement

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

  • #16
    Hello,
    Thank you for all your kind advice and patience.
    I have made some progress.
    Now I just have to
    1. include in the graph all the items
    2. change the legends ("mean of Not_applicable_to_my_activity" by "Not applicable to my activity" and "mean of Other" by "Other")
    3. place the percentages only on the blue line (not on the grid line)


    graph hbar Not_applicable_to_my_activity Other , over ( nom , sort( ccode )) ///
    bar(1, bcolor(blue*0.6)) bar(2, bcolor(grey*0.4)) ///
    title("Descriptive analysis of all respondents by profession for the option, 'not applicable to my activity' ")percent ///
    ytitle("Percent of Respondents") blabel(bar, format(%4.1f))


    Thank you for your help
    Lucia
    Attached Files

    Comment


    • #17
      For a good graph, I suggest that it is essential to show much shorter text.

      It's not clear why readers would be interested in "Not applicable" responses whereas what does "Other" mean?

      Both you and anyone else may find it easier to start with something like this:

      Code:
      * Example generated by -dataex-. For more info, type help dataex
      clear
      input int(Not_applicable_to_my_activity Other) byte ccode str52 plus_court
       18 252  1 "Adhere more often to recommended health care pathway"
        5 264 10 "Improves HCPs' feeling of professional value"        
        8 261 11 "Tensions between different hospital working cultures"
        5 264 12 "Increases risk of professional burnout"              
       14 255 13 "Reduces hospital costs"                              
      109 161  2 "Promotes spontaneous vaginal birth"                  
      121 149  3 "Less likely to have an episiotomy"                  
      108 162  4 "Less likely to have an epidural"                    
       18 252  5 "Increases women's satisfaction"                      
       16 254  6 "Accessible to women in vulnerable situations"        
       58 212  7 "Supports neonatal adaptation"                        
       43 227  8 "Increases risk of transfers to neonatal care unit"  
        4 266  9 "Increases HCPs' job satisfaction"                    
      end
      Last edited by Nick Cox; 02 May 2022, 06:21.

      Comment


      • #18
        In addition, as the percents of two components add to 100, why not just show whichever is more interesting?

        Comment


        • #19
          Hello, thank you for your advice. I have one more question, how do I remove "Other", with a percentage scale?
          Thanks
          Lucia

          Comment


          • #20
            With your dataset as something like that in #17 it's probably easiest to calculate what you want to show before you call up a graph command. For example, that might be

            Code:
            gen toshow = 100 * Other / (Other + Not) 

            Comment


            • #21
              Hello,
              Can anyone help me?
              I don't make much progress with Stata

              1. I need to increase the size of the graph
              2. put a small space between the two bars.
              3. increase the size of the legend rectangle
              Thank you very much for your help.
              Lucia


              graph hbar Agree Disagree , over (Items_01_pos, sort( ccode_01 )) percent blabel(bar, format(%2.1f) size (medium) tstyle (black) ) bar(1, fcolor(blue))bar(2, color(gs10)) legend(label(1 "Agree, Strongly agree") label(2 "Neither agree nor disagree, Disagree, Strongly disagree"))

              Attached Files

              Comment


              • #22
                You got good advice from Nick Cox. Shorten the text and lose one set of bars. Your audience is smart enough to figure out that given a binary choice, if 20% agreed, 80% disagreed. Doing this will free up some space. If you post a data example with shorter text, it should be easy to offer suggestions to sort out any aesthetic issues. If you are 100% set on your design, then you can wait to see if anyone is motivated to offer a solution. Otherwise, you may have to privately contract someone to fix the issues on your behalf.

                Comment


                • #23
                  Hello,
                  Thank you for your message.
                  I have shortened the text as suggested by Mr Nick. There are still problems with the size of the text.
                  Did you talk about someone in private? But I don't know anyone.
                  Do you have any idea?
                  Thank you very much.
                  Lucia

                  Comment


                  • #24
                    Can you post the data example with the shortened text? Copy and paste the result of

                    Code:
                    dataex Agree Disagree Items_01_pos ccode_01

                    Comment


                    • #25
                      The problem, it seems to me, is the size of the graph?

                      Comment


                      • #26
                        floris Lucia , thanks or posting your data, without which I was having a hard time understanding your problem and possible solutions.

                        I agree with Nick Cox that the readability of your graph comparing responses over 13 questions will be improved if you can abbreviate the questions in the graph labels. In this code I have suggested abbreviations for your questions which may not be the best abbreviations.

                        I'm not sure why you are analyzing the response "Not applicable" rather than the response "Other". Although I understand little of what you are doing, your code and graphs suggest that the answer "Other" expresses affirmation of the issue raised by the question, while the answer "Not applicable" expresses negation, not just negation of how applicable the question is, but negation of its importance in the respondent's clinical context. I would think you would want to analyze the affirmative responses rather than those that negate the importance of any given question.

                        In the code below, I accept your focus on "Not available" and work with that. But if you were to decide that you should focus instead on the "Other" response, you can switch the code around.

                        Also I note that your data contains the variables "profession" and "poste". You might want to analyze the impact of these variables on the responses to your questions. The recoding o your variables as zero/one variables should help with that. I show how you could do that with the tab commands at the end of the code. All of the code should work with version 12.

                        I begin by reading your data and making a new version of each of your 13 distinct variables.

                        Code:
                        version 12
                        use "données.dta", clear
                        
                        *    Create a new variable for each of the questions
                        *    which is coded as:
                        *        . 1  if the corresponding question was coded as 0
                        *        . 0  if the corresponding question was coded 4
                        
                        *    So for variable e1b the Stata command is
                        recode e1b (4=0) (0=1), gen(nae1b)
                        
                        *    Define a label for the new variable(s):
                        label define nalbl 0 "Other" 1 "Not applicable"
                        
                        *    Label the values of the new variable
                        label values nae1b nalbl
                        
                        *    Label the new variable
                        local vlbl = nom[1]
                        label variable nae1b "`vlbl'"
                        
                        tab nae1b, mi
                        
                        *    Since it's tedious to do this individually for each variable,
                        *    we create a loop to create variables e2b - e13b
                        foreach v of varlist e2b -e13b  {
                            // First get the question number from the variable name
                            local qno = substr("`v'",2,.)
                            local qno = substr("`qno'",1,strlen("`qno'")-1 )
                            // Use the question number to get the variable label
                            local vname = nom[`qno']
                            // Create and label the new variable
                            recode `v' (4=0) (0=1), gen(na`v')
                            label variable   na`v' "`vname'"
                            // And label its values
                            label values     na`v' nalbl
                        }
                        
                        *    Describe and summarize the new variable
                        des
                        sum
                        
                        *    Compare the original variable to the new variable with value labels:
                        tab nae1b e1b, missing
                        
                        *    Note that there are no missing values on the first question.
                        *    Compare the original variable to the new variable without value labels:
                        tab nae1b e1b, missing nolabel
                        Here are those two tabulations:

                        Code:
                        1. When WCC is |
                        applied, women |
                           adhere more |
                          often to the |
                           recommended |          E1b
                         health care p |         0          4 |     Total
                        ---------------+----------------------+----------
                                 Other |         0        252 |       252 
                        Not applicable |        18          0 |        18 
                        ---------------+----------------------+----------
                                 Total |        18        252 |       270 
                        
                        . 
                        . *       Note that there are no missing values on the first question. 
                        . *       Compare the original variable to the new variable without value labels:
                        . tab nae1b e1b, missing nolabel
                        
                           1. When |
                            WCC is |
                          applied, |
                             women |
                            adhere |
                        more often |
                            to the |
                        recommende |
                          d health |          E1b
                            care p |         0          4 |     Total
                        -----------+----------------------+----------
                                 0 |         0        252 |       252 
                                 1 |        18          0 |        18 
                        -----------+----------------------+----------
                             Total |        18        252 |       270
                        Because the new variables, nae1b - nae13b are coded as 1 if the response was 4 (i.e." Not applicable") and zero if the response was anything else, the means of the variables in the above summarize table can be interpreted as the proportion of respondents who said a given question was "Not applicable". Supposing you want to repreent those means by a bar graph covering all 13 questions ...

                        Code:
                        *    The following bar graph shows how the proportion of "not applicable" responses varies across your 13 questions.
                        gr hbar nae1b - nae13b, legend(off)  ///
                            showyvars blabel(bar,format(%6.2f))   ///
                            title("Proportion of respondants answering -Not applicable-", span just(left))  ///
                            name(firsttry, replace)
                        Here's the first try:

                        Click image for larger version

Name:	firsttry.png
Views:	1
Size:	211.1 KB
ID:	1662834

                        To improve the bar labels we can use the option -yvaroptions(relabel(...))- For example to relabel the bar for only the first question,

                        Code:
                        gr hbar nae1b - nae13b, legend(off)  ///
                            showyvars blabel(bar,format(%6.2f)) yvaroptions(relabel(1 "Increases adherence"))  ///
                            title("Proportion of respondants answering -Not applicable-", span just(left))   ///
                            name(onelabel, replace)
                        Click image for larger version

Name:	onelabel.png
Views:	1
Size:	207.6 KB
ID:	1662835

                        But if we want to relabel all thirteen bars, it's more convenient to put the code in a local macro like this:

                        Code:
                        *    But if we want to relabel all thirteen bars, it's more convenient to put the 
                        *    code in a local macro like this:
                            local relabel relabel(   ///
                                1  "Q1. Increases adherence"  ///
                                2  "Q2. Increases vaginal birth" ///
                                3  "Q3. Reduces episiotomy"  ///
                                4  "Q4. Reduces epidural"  ///
                                5  "Q5. Increases satisfaction"  ///
                                6  "Q6. Increases accessibility"  ///
                                7  "Q7. Improves neonatal adaptation"  ///
                                8  "Q8. Increases neonatal care (-)"  ///
                                9  "Q9. Increases HCP's job satisfaction"  ///
                                10 "Q10. Increases HCP's prof. value"  ///
                                11 "Q11. Increases work tension (-)"  ///
                                12 "Q12. Increases risk of burnout (-)"  ///
                                13 "Q13. Reduces hospital costs"  )
                        
                        *    This is what the option relabel now looks like
                        *    (after stripping out extraneous blanks)
                        local relabel = stritrim(`"`relabel'"')
                        di `"`relabel'"'
                        
                        *    Here's the horizontal bar graph for all your 13 questions, with abreviated variable labels.
                        gr hbar nae1b - nae13b, legend(off)  /// 
                            showyvars blabel(bar,format(%6.2f)) yvaroptions(`relabel')  ///
                            title("Proportion of respondants answering -Not applicable-", span just(left))   ///
                            name(alllabels, replace)
                        Which yields the following graph:
                        Click image for larger version

Name:	alllabels.png
Views:	1
Size:	252.5 KB
ID:	1662836

                        Of course you can change the graph scheme to fit your preferences. I am using -s2clr_on_white- available from:

                        Code:
                        view net describe scheme_s2clr_on_white, from(http://digital.cgdev.org/doc/stata/MO/Misc)
                        For example, ff your publication outlet prefers a monochormatic display, try:

                        Code:
                        *    And here it is again with a black_and_white color scheme
                        gr hbar nae1b - nae13b, legend(off)  /// 
                            showyvars blabel(bar,format(%6.2f)) yvaroptions(`relabel')  ///
                            title("Proportion of respondants answering -Not applicable-", span just(left))   ///
                            name(alllabelssj, replace) scheme(sj)
                        In your posts #23 and #25 you are wondering how to control the size of the graph. By adding the sub-option -label(labsize(small))- inside the option yvaroptions()- , you can control the size of the question text which labels the bars.

                        Code:
                        gr hbar nae1b - nae13b, legend(off)  /// 
                            showyvars blabel(bar,format(%6.2f)) yvaroptions(`relabel' label(labsize(small)))  ///
                            title("Proportion of respondants answering -Not applicable-", span just(left))   ///
                            name(smalleralllabel, replace)
                        Which produces this graph:
                        Click image for larger version

Name:	smalleralllabel.png
Views:	1
Size:	225.7 KB
ID:	1662837

                        Finally, I am wondering whether you will want to explore the dependence of the answers to your 13 questions on one or more of the other variables in your data.

                        Here's a tabulation of question 3 giving the probability of the responses "Other" and "Not Applicable" by profession. I see that the proportion of respondents answering "Not applicable" varies from 89% fr profession #2 down to a low of 7% for profession #3. So it looks as though the variable has a big impact on question #3. Repeating a similar analysis for your other questions shows varying degrees of influence of profession on the the proportion giving the answer "Not applicable". (If you decide to focus on the response "Other", becuase it is more affirmative, I think the result will be the mirror image of these results with "Not applicable".)

                        Code:
                        . tab profession nae3b , chi2 row 
                        
                        +----------------+
                        | Key            |
                        |----------------|
                        |   frequency    |
                        | row percentage |
                        +----------------+
                        
                                   |    3. When care is
                                   | centred on the woman,
                                   |  the newborn and the
                                   |   family, women are
                                   |         less
                        Profession |     Other  Not appli |     Total
                        -----------+----------------------+----------
                                 1 |       104         20 |       124 
                                   |     83.87      16.13 |    100.00 
                        -----------+----------------------+----------
                                 2 |        10         85 |        95 
                                   |     10.53      89.47 |    100.00 
                        -----------+----------------------+----------
                                 3 |        27          2 |        29 
                                   |     93.10       6.90 |    100.00 
                        -----------+----------------------+----------
                                 4 |         3         10 |        13 
                                   |     23.08      76.92 |    100.00 
                        -----------+----------------------+----------
                                 5 |         5          4 |         9 
                                   |     55.56      44.44 |    100.00 
                        -----------+----------------------+----------
                             Total |       149        121 |       270 
                                   |     55.19      44.81 |    100.00 
                        
                                  Pearson chi2(4) = 140.1493   Pr = 0.000
                        Because your dependent variable, nae3b is dichotomous with values of zero and one, you could also analyze this bivariate regression with a logit model. With any version of Stata newer than 11, you can represent the five professions with a factor variable, -i.profession-.: Here's the logit regression:

                        Code:
                         
                        . logit nae3b i.profession
                        
                        Iteration 0:   log likelihood = -185.69527  
                        Iteration 1:   log likelihood =  -107.7378  
                        Iteration 2:   log likelihood = -107.23807  
                        Iteration 3:   log likelihood = -107.23371  
                        Iteration 4:   log likelihood = -107.23371  
                        
                        Logistic regression                                     Number of obs =    270
                                                                                LR chi2(4)    = 156.92
                                                                                Prob > chi2   = 0.0000
                        Log likelihood = -107.23371                             Pseudo R2     = 0.4225
                        
                        ------------------------------------------------------------------------------
                               nae3b | Coefficient  Std. err.      z    P>|z|     [95% conf. interval]
                        -------------+----------------------------------------------------------------
                          profession |
                                  2  |   3.788725   .4139808     9.15   0.000     2.977337    4.600112
                                  3  |   -.954031   .7724328    -1.24   0.217    -2.467971    .5599094
                                  4  |   2.852631   .7021031     4.06   0.000     1.476535    4.228728
                                  5  |   1.425515   .7138735     2.00   0.046     .0263487    2.824681
                                     |
                               _cons |  -1.648659   .2441626    -6.75   0.000    -2.127209   -1.170109
                        ------------------------------------------------------------------------------
                        Note that both the tabulation and the logit regression compute a Chi^2 statistic with four degrees of freedom. Although the statistical models are somewhat different, the chi^2 statistics are about the same size. Apparently question #3 regarding of whether your intervention WCC reduces the frequency of epistiotimies receives very different responses across the professional categories in your study.


                        Last edited by Mead Over; 03 May 2022, 12:37.

                        Comment


                        • #27
                          Hello Mead Over,
                          Thank you for your precious advice, but I'm sorry, I have finished graph 1 (the one you are talking about) and I have started graph 2. (the last one I sent).
                          I think that's why there was a confusion.

                          My problem is that the size of the graph 2 is too small and I would like to enlarge it.

                          The items in graph 2 are the same as in graph 1, and even using the shortened items that Mr Nick suggests, but it doesn't fit. I don't want to shorten them any more.
                          I tried to "split" them in two parts, but I can't find the Stata command (I don't no, if it exists?).

                          I am very new to Stata.
                          About the regression, thank you very much. I don't know if I can use it, because the research purpose is different. But I will think again.

                          Sincerely
                          Lucia
                          In the annexe, you can see the graph 1 (finish) and the start of graph 2
                          Attached Files

                          Comment


                          • #28
                            When you post a question, please post the code you used to make the graph. In the left panel, there is no title to explain what is measured by the bars. I assume that you are measuring the percentage of repondents reporting "Not applicable". In the right panel, the legend is taking up space. You can move the legend to the right margin using the -legend(pos(3))- option. Best of luck.

                            Comment

                            Working...
                            X