Announcement

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

  • Histogram axis ??unrelated to data

    I wonder if someone could explain to me where Stata is finding my y axis when I plot this histogram? I want to to read N with whole numbers, or % of total. I know how to change the actual titles for the axis, but not to get Stata to recognise the graph to be N or % of total.
    This is to plot the spread of ages in a study of 607 patients.
    This is the beginning of the table:
    . tab Age_num

    Age | Freq. Percent Cum.
    ------------+-----------------------------------
    9 | 1 0.17 0.17
    19 | 1 0.17 0.34
    21 | 1 0.17 0.50
    23 | 1 0.17 0.67
    25 | 1 0.17 0.84
    27 | 1 0.17 1.01
    28 | 1 0.17 1.17
    29 | 3 0.50 1.68
    33 | 2 0.34 2.01
    Then with histogram Age_num I get this graph, it is the red box that is my problem and I don't understand why Stata is showing me this - neither the frequency nor the Percentage correlates to a peak of just over 0.04??? Many thanks for any explanations
    Click image for larger version

Name:	Graph capture axis problem.JPG
Views:	2
Size:	27.1 KB
ID:	1393386
    Attached Files

  • #2
    The output of help histogram suggests that
    Code:
    histogram Age_num, frequency
    will give you frequencies on the vertical axis.

    Comment


    • #3
      The help for histogram is instructive. Right near the top you get to see a list of various options, including


      density draw as density; the default
      fraction draw as fractions
      frequency draw as frequencies
      percent draw as percentages
      You're seeing the density. You want a different option.

      Here density means probability density, in your case probability per year. If you don't know about probability density, it is explained in some introductory and essentially all intermediate surveys of statistics, and you can Google in any case.

      The total area in the histogram bars is the total probability, necessarily 1.

      To check that out for your example, note that your highest density is about 0.04. The average density by eye is is around 0.01 and the horizontal width of the histogram is about 90 years. Multiply: 0.01 per year x 90 years = 0.90, which is the right order. Evidently the mean bar height is a little more than 0.01.

      To get a nicer histogram, you need to do a little more work, not just to get fractions. I would try

      Code:
      histogram Age_num, fraction start(0) width(4)
      so that your bars line up a little more closely with your axis ticks. If you want percents, the option is indicated.

      Moral: The help is there to explain.

      Comment

      Working...
      X