Announcement

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

  • Histogram - line only

    Hello everybody,

    I would like to create histogram in Stata, but instead of columns I would like to draw line that represents frequency distribution of variable. I hope you understand my question and know solution to my problem.

    Thank you.

  • #2
    I expressed the same wish (I think) a few years ago, but it's not possible at this point. Please see http://www.stata.com/statalist/archi.../msg01137.html .
    David Radwin
    Senior Researcher, California Competes
    californiacompetes.org
    Pronouns: He/Him

    Comment


    • #3
      Is this what you want?

      Code:
      sysuse auto, clear
      gen weightgrp = 500*floor(weight/500) + 250
      gen n=1
      collapse (sum) n , by(weightgrp)
      twoway line n weightgrp , sort xlabel(1500(500)5000)

      Comment


      • #4
        Svend has some neat code that will give you a first stab. The problem gets worse if you have empty bins, which by definition will be not in the reduced dataset. You will get an incorrect connection between positive frequencies either side of the bin that is empty.

        Comment


        • #5
          This may not be what you want, but you can use kdensity to achieve a similar effect:
          Code:
          sysuse auto, clear
          kdensity weight

          Comment


          • #6
            In my opinion, your best bet for overlapping histograms is to make one histogram with a solid outline and transparent fill (color(none)) and the other histogram with a washed-out color, like this:

            Code:
            sysuse nlsw88
            twoway (histogram wage if union==1, frequency color(gs11) lwidth(none)) ///
                   (histogram wage if union==0, frequency color(none) lwidth(medium) lcolor(navy) ///
                   legend(order(2 "Non-union" 1 "Union")))
            David Radwin
            Senior Researcher, California Competes
            californiacompetes.org
            Pronouns: He/Him

            Comment


            • #7
              Also see http://www.statalist.org/forums/foru...963#post821963 .
              David Radwin
              Senior Researcher, California Competes
              californiacompetes.org
              Pronouns: He/Him

              Comment

              Working...
              X