Announcement

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

  • P.D.F. plotting

    Hi everyone

    I just purchased Stata16 the other day. I am trying to get a grip on one elementary statistical operation such as plotting a P.D.F. over a frequency histogram of a continuous variable, but I cannot find a way to do it. From all the high level statistical features of the software, the simple ones are hardly visible (to me at least). Can anyone help and describe how this works in steps? Thanks

  • #2
    Perhaps the histogram command (note: this is different from, though similar to, the twoway histogram command) will do what you need. The documentation, with examples, is in the Stata Base Reference Manual PDF included with your Stata installation and accessible through Stata's Help menu.

    I'm sympathetic to you as a new user of Stata - it's a lot to absorb. I will say that, compared to some of the other statistical software packages I have used, I have found the graphics commands in Stata somewhat less approachable, rather more oriented to complete flexibility and control, and consequently less immediately approachable. They were not where I started in learning Stata.

    When I began using Stata in a serious way, I started, as have others here, by reading my way through the Getting Started with Stata manual relevant to my setup. Chapter 18 then gives suggested further reading, much of which is in the Stata User's Guide, and I worked my way through much of that reading as well. There are a lot of examples to copy and paste into Stata's do-file editor to run yourself, and better yet, to experiment with changing the options to see how the results change.

    All of these manuals are included as PDFs in the Stata installation (since version 11) and are accessible from within Stata - for example, through the PDF Documentation section of Stata's Help menu. The objective in doing the reading was not so much to master Stata as to be sure I'd become familiar with a wide variety of important basic techniques, so that when the time came that I needed them, I might recall their existence, if not the full syntax, and know how to find out more about them in the help files and PDF manuals.

    Comment


    • #3
      Seems that you can use -dpplot- command written by Nick Cox. The command was designed to make density probability plots and you can add histogram by its -plot()- option. You can install it by typing "ssc install dpplot" in Stata command window.
      Code:
      sysuse auto
      dpplot price, plot(histogram price, bcolor(none)) //If you use Stata13
      dpplot price, plot(histogram price, bcolor(navy%50)) //If you use Stata16, you can set color opacity

      Comment


      • #4
        I have to doubt that dpplot is what is being sought here. This isn't difficult for the probability density version of a histogram.


        Code:
        sysuse auto, clear
        twoway histogram price || kdensity price
        For the frequency version, I think you'd need to run kdensity to generate the density function and then scale by bin width and sample size.

        Note that the Stata Journal version of dpplot is definitive:


        SJ-7-4 gr0012_1 . . . . . . . . . . . . . . . . . Software update for dpplot
        (help dpplot if installed) . . . . . . . . . . . . . . . . N. J. Cox
        Q4/07 SJ 7(4):593
        addplot() option added

        SJ-5-2 gr0012 . . . . . . . . . . Speaking Stata: Density probability plots
        (help dpplot if installed) . . . . . . . . . . . . . . . . N. J. Cox
        Q2/05 SJ 5(2):259--273
        discusses use of density probability plots for determining
        the density function of a continuous variable, given a data
        sample; compares density probability plots with histograms,
        kernel density estimation, and quantile--quantile plots

        but as said I doubt it's what you seek.
        Last edited by Nick Cox; 25 Aug 2019, 01:59.

        Comment


        • #5
          Originally posted by Chen Samulsion View Post
          Seems that you can use -dpplot- command written by Nick Cox. The command was designed to make density probability plots and you can add histogram by its -plot()- option. You can install it by typing "ssc install dpplot" in Stata command window.
          Code:
          sysuse auto
          dpplot price, plot(histogram price, bcolor(none)) //If you use Stata13
          dpplot price, plot(histogram price, bcolor(navy%50)) //If you use Stata16, you can set color opacity
          I tried this, it worked....thanks

          Comment


          • #6
            Hrvoje Vucemilovic, you'd better follow Nick Cox's advice, he is a real expert.

            Comment

            Working...
            X