Announcement

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

  • How to create stacked bar charts for likert-type data?

    Dear Stata List,

    I would like to create sets of stacked bar charts from survey data that is comprised of attitudinal questions with responses based on 6-point likert-type scales (Strongly agree - Strongly Disagree). The charts would be similar to those found here: http://www.r-bloggers.com/plotting-likert-scales/ and am especially interested in the third one which charts percentages. In addition to sets of items, I will also need side-by-side comparisons of groups (e.g., gender, class, etc.). If it could include the item mean that would be extremely helpful! (Not asking for much, right?)

    I am relatively new to stata and am wasting a lot of time (as in days) searching for examples and exploring the various menu options. From one Stata article it appears tableplot holds promise and I have loaded it, but have not gotten anywhere.

    Am using Stata 14.


    Many thanks in advance,
    John

  • #2
    How to win friends and influence people was the title of a once very famous book...

    I am the author of tableplot (SSC), which is still accessible but not being developed and not recommended by me for your purpose.

    I don't know how 6 levels come out of a Strongly Disagree ... Strongly Agree scale. I am trusting that detail is not important.

    The auto data contain an ordered response with 5 levels, namely rep78. slideplot (SSC) is perhaps the closest to what you identify. I'd prefer the results of tabplot (also SSC). Also search spineplot

    Code:
    sysuse auto, clear
    
    * if not installed already 
    ssc inst slideplot 
    
    slideplot hbar rep78, pos(3 4 5) neg(1 2) by(foreign) ///
    bar(1, bcolor(blue*0.4)) ///
    bar(2, bcolor(blue*0.8)) ///
    bar(3, bcolor(red*0.2))  ///
    bar(4, bcolor(red*0.6))  /// 
    bar(5, bcolor(red)) legend(row(1)) percent
    
    * if not installed already 
    ssc inst tabplot 
    
    tabplot for rep78, percent(foreign) horizontal ///
    showval(offset(0.05) mlabsize(*1.1) mlabcolor(black)) ///
    bfcolor(none) height(0.7) xsc(r(0.8 .))

    Click image for larger version

Name:	slideplot1.png
Views:	1
Size:	11.2 KB
ID:	1319022



    Click image for larger version

Name:	tabplot1.png
Views:	1
Size:	13.0 KB
ID:	1319023

    Comment


    • #3
      Thanks! It's a good start!

      Comment


      • #4
        The post below is a duplicate from here and here.

        For those users who visit this post and might be unaware, note that Nick published the module floatplot (29 May 2021, but now in version 1.0.3, 31 October 2022):
        to draw floating or sliding stacked bar plot - floatplot produces a floating or sliding stacked bar plot showing percents (or optionally proportions or frequencies) of categories of a numeric outcome variable numvar by zero, one, or two other categorical variables. The plot is most helpful if categories of an outcome variable have a natural or conventional pre-defined order. Although there is no formal check, the design of the plot tacitly assumes a modest number of distinct categories, say between 2 and 9. The commmand is a wrapper for a call to twoway rbar for showing bars and twoway scatter for showing text.
        It can be installed by using this code:
        Code:
        ssc install floatplot , replace
        The examples in the help demonstrate how to create a floating or sliding stacked bar plot for frequencies, proportions, or percents. Very useful indeed to visualize the so-called Likert scale response variables also over categories.
        http://publicationslist.org/eric.melse

        Comment

        Working...
        X