Announcement

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

  • Problems with histogram displaying the maximum value incorrectly

    I am using the histogram command to plot data from a small sample of exam scores (26 observations). The scores are integer numbers, so I am using the w(1) option sp that histogram displays one integer value per bin.

    Oddly, whatever the top value is in the distribution of exam scores appears to be plotted one bin too low. (For example, if the top score is 84, it is plotted in the “83” bin; if the top score is 89 it is plotted in the “88” bin.) I have experimented a bit with different values, and I can make formerly incorrectly plotted observations be plotted correctly by adding a new top value (which is then itself incorrectly plotted).

    I have attached a log file that has screen shots of the corresponding histograms inserted. I have also listed the data, so it should be possible to recreate what I have done. Is there something I am not understanding about how the histogram command works, or with the options I am specifying?
    Attached Files

  • #2
    Many of us can't even open that attachment. MS Word is not a universal standard.

    Best to show the graphs as .png attachments and give the data via CODE delimiters.

    This is explained in the FAQ Advice recommended to all posters http://www.statalist.org/forums/help#stata

    Comment


    • #3
      Here is problem that Meghan Busse is demonstrating:
      Code:
      clear
      input x
      52 
      54 
      54 
      66 
      66 
      66 
      66 
      68 
      69 
      70 
      71 
      71 
      71 
      72 
      73 
      73 
      74 
      75 
      75 
      76 
      77 
      78 
      78 
      81 
      82 
      84
      end
      histogram x,w(1) xlabel(81 82 83 84  ,labsize(*.75))
      Click image for larger version

Name:	Graph1.png
Views:	1
Size:	25.6 KB
ID:	1311679


      There is an actual value for 81, 82, and 84, but the histogram show 81,82, and 83.

      If you add an 83 to the data set then the histogram shows two values for the 83 bin:

      Click image for larger version

Name:	Graph2.png
Views:	1
Size:	26.3 KB
ID:	1311680

      Comment


      • #4
        The problem is that you're treating discrete data as continuous. Add the discrete option to the command and it'll show fine.
        Alfonso Sanchez-Penalver

        Comment

        Working...
        X