Announcement

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

  • Plot cumulative distribution by value

    I want to plot the cumultive distribution by BMI categories. How do I do that?

  • #2
    The cumulative distribution of ... some other variable? distplot from the Stata Journal allows such plots.

    However, categorisation of BMI measurements throws away much of the information they contain. It's better for most statistical and even medical purposes to use raw BMI measurements.

    Comment


    • #3
      Thank you! I have installed it now, and as i understand it from the help file i should be able to use this code:

      . distplot Ferritin by(BMI_cat)

      However, I get this error message: factor-variable and time-series operators not allowed

      Comment


      • #4
        You need a comma before any option calls.

        Comment


        • #5
          Thank you Nick! Is it possible to get them all in the same graph instead of four, to overlay them? And how do I change the levels on the y-axis?
          Click image for larger version

Name:	Graph.jpg
Views:	1
Size:	32.2 KB
ID:	1743209

          Comment


          • #6
            Yes; that's the over() option documented in the help and the ylabel() option that is standard for twoway.

            Comment


            • #7
              Great! Thank you so much Nick! I have one last question. Can I make the axis stop at 140?

              distplot Ferritin, over(BMI_cat) ylabel(0(.1)1) xlabel(0(20)140)
              Click image for larger version

Name:	Graph2.jpg
Views:	1
Size:	34.8 KB
ID:	1743214

              Comment


              • #8
                You can always call the command with a restriction such as

                Code:
                if ferritin < 140
                But then calculations will be restricted to those observations.

                The underlying issues here are perhaps twofold:

                1. A quantile plot usually will work better to show the structure of tails.

                2. You might be better off with a transformed scale, especially logarithmic.

                Comment

                Working...
                X