Announcement

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

  • Plot of likert variables

    Hi Stata folks,

    I have a dataset with several questions whose answers are likert scale as shown below


    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input byte(id Q1 Q2 Q3)
      1 2 5 3
      2 2 5 3
      3 2 5 3
      4 2 5 3
      5 2 5 3
      6 2 5 3
      7 2 5 3
      8 2 5 3
      9 2 5 3
     10 2 5 3
     11 2 5 3
     12 2 5 3
     13 2 5 3
     14 2 5 3
     15 2 5 3
     16 2 5 3
     17 1 5 3
     18 1 5 3
     19 1 5 3
     20 1 5 3
     21 1 5 3
     22 1 5 3
     23 1 5 3
     24 1 5 3
     25 1 5 3
     26 1 5 3
     27 1 5 3
     28 1 4 3
     29 1 4 3
     30 1 4 3
     31 1 4 3
     32 1 4 3
     33 1 4 1
     34 1 4 1
     35 1 4 1
     36 1 4 1
     37 1 4 1
     38 1 4 1
     39 1 4 1
     40 1 4 1
     41 3 4 1
     42 3 4 1
     43 3 4 1
     44 3 4 1
     45 3 4 1
     46 3 4 1
     47 3 4 1
     48 3 4 1
     49 3 4 5
     50 3 4 5
     51 3 2 5
     52 3 2 5
     53 3 2 5
     54 3 2 5
     55 3 2 5
     56 3 2 5
     57 3 2 5
     58 3 2 4
     59 3 2 4
     60 3 2 4
     61 3 2 4
     62 3 2 4
     63 3 2 4
     64 3 2 4
     65 3 1 4
     66 3 1 4
     67 3 1 4
     68 3 1 4
     69 3 1 4
     70 5 1 4
     71 5 1 4
     72 5 1 4
     73 5 1 4
     74 5 1 4
     75 5 1 4
     76 5 1 4
     77 5 1 2
     78 5 3 2
     79 5 3 2
     80 5 3 2
     81 5 3 2
     82 5 3 2
     83 5 3 2
     84 5 3 2
     85 5 3 2
     86 5 3 2
     87 5 3 2
     88 4 3 2
     89 4 3 2
     90 4 3 2
     91 4 3 2
     92 4 3 2
     93 4 3 2
     94 4 3 2
     95 4 3 2
     96 4 3 2
     97 4 3 2
     98 4 3 2
     99 4 3 2
    100 4 3 2
    end
    label values Q1 likert
    label values Q2 likert
    label values Q3 likert
    label def likert 1 "Strongly agree", modify
    label def likert 2 "Agree", modify
    label def likert 3 "Neither agree nor disagree", modify
    label def likert 4 "Disagree", modify
    label def likert 5 "Strongly disagree", modify

    I would like to plot a graph of the variables in the same graph as shown below for comparison

    Click image for larger version

Name:	example.png
Views:	1
Size:	26.2 KB
ID:	1658166



    I would appreciate any guidance on how to achieve this in Stata.

    Thanks in advance!

  • #2
    Thanks for the data example.

    FWIW: the surname or family name "Likert" honours the scientist Rensis Likert. I don't think anyone objects to the spelling Likert, although some don't much like likert because it ignores that detail.

    Only your data structure, which is natural for other purposes, stands in the way of getting a comparative graph easily. However, the stacked bar design although popular is seriously flawed in practice.

    Here are some results using floatplot from SSC and tabplot from the Stata Journal. Longer discussions can be found by searching the forum.

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input byte(id Q1 Q2 Q3)
      1 2 5 3
      2 2 5 3
      3 2 5 3
      4 2 5 3
      5 2 5 3
      6 2 5 3
      7 2 5 3
      8 2 5 3
      9 2 5 3
     10 2 5 3
     11 2 5 3
     12 2 5 3
     13 2 5 3
     14 2 5 3
     15 2 5 3
     16 2 5 3
     17 1 5 3
     18 1 5 3
     19 1 5 3
     20 1 5 3
     21 1 5 3
     22 1 5 3
     23 1 5 3
     24 1 5 3
     25 1 5 3
     26 1 5 3
     27 1 5 3
     28 1 4 3
     29 1 4 3
     30 1 4 3
     31 1 4 3
     32 1 4 3
     33 1 4 1
     34 1 4 1
     35 1 4 1
     36 1 4 1
     37 1 4 1
     38 1 4 1
     39 1 4 1
     40 1 4 1
     41 3 4 1
     42 3 4 1
     43 3 4 1
     44 3 4 1
     45 3 4 1
     46 3 4 1
     47 3 4 1
     48 3 4 1
     49 3 4 5
     50 3 4 5
     51 3 2 5
     52 3 2 5
     53 3 2 5
     54 3 2 5
     55 3 2 5
     56 3 2 5
     57 3 2 5
     58 3 2 4
     59 3 2 4
     60 3 2 4
     61 3 2 4
     62 3 2 4
     63 3 2 4
     64 3 2 4
     65 3 1 4
     66 3 1 4
     67 3 1 4
     68 3 1 4
     69 3 1 4
     70 5 1 4
     71 5 1 4
     72 5 1 4
     73 5 1 4
     74 5 1 4
     75 5 1 4
     76 5 1 4
     77 5 1 2
     78 5 3 2
     79 5 3 2
     80 5 3 2
     81 5 3 2
     82 5 3 2
     83 5 3 2
     84 5 3 2
     85 5 3 2
     86 5 3 2
     87 5 3 2
     88 4 3 2
     89 4 3 2
     90 4 3 2
     91 4 3 2
     92 4 3 2
     93 4 3 2
     94 4 3 2
     95 4 3 2
     96 4 3 2
     97 4 3 2
     98 4 3 2
     99 4 3 2
    100 4 3 2
    end
    label values Q1 likert
    label values Q2 likert
    label values Q3 likert
    label def likert 1 "Strongly agree", modify
    label def likert 2 "Agree", modify
    label def likert 3 "Neither agree nor disagree", modify
    label def likert 4 "Disagree", modify
    label def likert 5 "Strongly disagree", modify
    
    reshape long Q, i(id) j(question)
    set scheme s1color 
    
    floatplot Q, over(question) centre(3) ytitle(Likert response) fcolors(red*0.6 red*0.2 blue*0.2 blue*0.6 blue) lcolors(red red blue blue blue) vertical name(G1, replace)
    
    tabplot Q question, ytitle(Likert response) separate(Q) percent(question) subtitle(% on question) showval ///  
    bar5(fcolor(red*0.6) lcolor(red)) bar4(fcolor(red*0.2) lcolor(red)) /// 
    bar3(fcolor(blue*0.2) lcolor(blue)) bar2(fcolor(blue*0.6) lcolor(blue)) bar1(color(blue)) name(G2, replace)
    Click image for larger version

Name:	okiya_likert1.png
Views:	1
Size:	24.9 KB
ID:	1658205
    Click image for larger version

Name:	okiya_likert2.png
Views:	1
Size:	26.1 KB
ID:	1658206
    Some of the graphical issues arising:

    1. The fact that percents of a total sum to 100 is inevitable and unsurprising. There is no reason to emphasise it by choice of design.

    2. Stacked designs make some comparisons trickier, especially if any categories are rare or absent (on the face of it, not an issue with your data).

    3. A legend is at best a necessary evil so -- if used at all -- it should be placed so that back and forth between the graph and the legend is as easy as possible.

    4. A colour scheme for a graded response should itself be graded. A sequence from red to blue meets many preferences, subject to matching the subject matter and the cultural preferences of the readership.

    I don't and won't spell out how to get a stacked bar chart, but it's easier with this data structure.

    Comment


    • #3
      I note too late that I've not been consistent on ordering or colour schemes between the graphs. Oh well, that is easy enough to fix.

      Also, I think most researchers run scales from Strongly disagree to Strongly agree, but that is at best a convention, not a rule.

      Comment


      • #4
        Thanks so much Nick Cox As always you are ready with elegant solutions to Stata challenges!!!

        Comment


        • #5
          Here's how to get floatplot consistently with tabplot.

          Code:
          * Example generated by -dataex-. For more info, type help dataex
          clear
          input byte(id Q1 Q2 Q3)
            1 2 5 3
            2 2 5 3
            3 2 5 3
            4 2 5 3
            5 2 5 3
            6 2 5 3
            7 2 5 3
            8 2 5 3
            9 2 5 3
           10 2 5 3
           11 2 5 3
           12 2 5 3
           13 2 5 3
           14 2 5 3
           15 2 5 3
           16 2 5 3
           17 1 5 3
           18 1 5 3
           19 1 5 3
           20 1 5 3
           21 1 5 3
           22 1 5 3
           23 1 5 3
           24 1 5 3
           25 1 5 3
           26 1 5 3
           27 1 5 3
           28 1 4 3
           29 1 4 3
           30 1 4 3
           31 1 4 3
           32 1 4 3
           33 1 4 1
           34 1 4 1
           35 1 4 1
           36 1 4 1
           37 1 4 1
           38 1 4 1
           39 1 4 1
           40 1 4 1
           41 3 4 1
           42 3 4 1
           43 3 4 1
           44 3 4 1
           45 3 4 1
           46 3 4 1
           47 3 4 1
           48 3 4 1
           49 3 4 5
           50 3 4 5
           51 3 2 5
           52 3 2 5
           53 3 2 5
           54 3 2 5
           55 3 2 5
           56 3 2 5
           57 3 2 5
           58 3 2 4
           59 3 2 4
           60 3 2 4
           61 3 2 4
           62 3 2 4
           63 3 2 4
           64 3 2 4
           65 3 1 4
           66 3 1 4
           67 3 1 4
           68 3 1 4
           69 3 1 4
           70 5 1 4
           71 5 1 4
           72 5 1 4
           73 5 1 4
           74 5 1 4
           75 5 1 4
           76 5 1 4
           77 5 1 2
           78 5 3 2
           79 5 3 2
           80 5 3 2
           81 5 3 2
           82 5 3 2
           83 5 3 2
           84 5 3 2
           85 5 3 2
           86 5 3 2
           87 5 3 2
           88 4 3 2
           89 4 3 2
           90 4 3 2
           91 4 3 2
           92 4 3 2
           93 4 3 2
           94 4 3 2
           95 4 3 2
           96 4 3 2
           97 4 3 2
           98 4 3 2
           99 4 3 2
          100 4 3 2
          end
          label values Q1 likert
          label values Q2 likert
          label values Q3 likert
          label def likert 5 "Strongly agree", modify
          label def likert 4 "Agree", modify
          label def likert 3 "Neither agree nor disagree", modify
          label def likert 2 "Disagree", modify
          label def likert 1 "Strongly disagree", modify
          
          reshape long Q, i(id) j(question)
          replace Q = 6 - Q
          set scheme s1color
          
          floatplot Q, over(question) centre(3) ytitle(Likert response) fcolors(red*0.6 red*0.2 blue*0.2 blue*0.6 blue) lcolors(red red blue blue blue) vertical name(G1, replace)
          Last edited by Nick Cox; 07 Apr 2022, 02:25.

          Comment


          • #6
            Thanks Nick Cox for the additional insights. This is super!!

            Comment

            Working...
            X