Announcement

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

  • plotting two curves on same chart

    Hello
    I have two distributions of my dependent variable 'gcp', one for males and one for females.
    I would like to plot their distributions on the same chart...
    I don't think the hist options are good for this, as I don't actually want to plot the frequency / density in a proper histogram with bars (eg 'hist gcp'), I just want the overarching curve for each of them....

    Can anybody help?

  • #2
    try -kdensity- with the addplot option for a second -kdensity-; see
    Code:
    help kdensity

    Comment


    • #3

      Code:
      help kdensity
      may be the pointer you seek. Otherwise "overarching curve" could mean several different things.

      Comment


      • #4
        Originally posted by Nick Cox View Post
        Code:
        help kdensity
        may be the pointer you seek. Otherwise "overarching curve" could mean several different things.
        Hi there,
        sorry, I guess what I meant is that I want the equivalent of a smoothed distribution of my data overlying my histogram, without the histogram itself.
        Basically, something exactly like this:

        I ran the code "kdensity gcp if sex==0, addplot(kdensity gcp if sex==1) but this does not seem to be working. I get the error message, "invalid addplot". Do you have any pointers?
        Click image for larger version

Name:	Screen Shot 2018-07-09 at 2.08.40 PM.png
Views:	1
Size:	10.3 KB
ID:	1452493

        Last edited by Alan Jeddi; 09 Jul 2018, 07:12.

        Comment


        • #5
          Works for me:

          Code:
          . sysuse auto
          (1978 Automobile Data)
          
          . kdensity mpg if foreign, addplot(kdensity mpg if !foreign)
          So, I have to guess that your code is not what you said, or that your Stata is not up-to-date. You don't give a data example for us to test your code.

          Comment

          Working...
          X