Announcement

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

  • Problem with fweight and bar graphs

    This is probably an extremely elementary question and I am so sorry in advance.
    I have a dataset of 420 comments that are followed by 31 columns of various variables. For each variable, either a 0 or 1 was assigned if the comment met that criteria. For example,

    CommentID Recommendation Deserve SOL Unmerit etc.....
    1 139 0 1 1 0
    2 14 0 1 0 1
    3 8 1 0 1 1

    I need to make a bar graph that displays the mean of the variables weighted by how many recommendations each variable had. I know that I need to use the fweight command but my code is definitely wrong.

    This is what I had:
    graph bar Deserve SOL Unmerit etc [fweight=Recommend]. Thank you so much!
    Last edited by Hannah Sexton; 09 Jul 2019, 07:39.

  • #2
    What do you get with this code? It works for me and the graph seems to represent the weighted means.

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input byte commentid int recommendation byte(deserve sol unmerit etc)
    1 139 0 1 1 0
    2  14 0 1 0 1
    3   8 1 0 1 1
    end
    
    mean deserve sol unmerit etc // unweighted, just for demonstration
    
    mean deserve sol unmerit etc [fweight=recommend] // weighted
    
    graph bar deserve sol unmerit etc [fweight=recommend]
    David Radwin, Senior Research Associate
    Education and Workforce Development, RTI International
    2150 Shattuck Ave. Suite 800, Berkeley, CA 94704
    Phone: 510-665-8274
    www.rti.org/education
    Pronouns: He/Him

    Comment


    • #3
      Thank you!

      Comment

      Working...
      X