Announcement

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

  • Multiple kdensity curves in one plot

    Hello all,

    I would like to compare the log earnings of males and females in 1996 using a kdensity plot. I followed the advice here (http://ewens.caltech.edu/2013/06/13/...plot-in-stata/) but it doesn't seem to be working. The two commands work in isolation to each other, but that is futile as I don't want to have two plots, I want one!

    Code:
    kdensity log if employee == 1 & indus != 1 & New_Gender==1  [aw=pweight], gaussian n(1000) width(0.2)), addplot (kdensity log if employee == 1 & indus != 1 & New_Gender==2  [aw=pweight], gaussian n(1000) width(0.2))

  • #2
    Code:
    sysuse auto, clear
    twoway (kdensity price if foreign==0)(kdensity price if foreign==1)

    Comment


    • #3
      On "doesn't seem to be working" and such wording, see FAQ Advice Section 12.

      It's easy to get confused between kdensity and twoway kdensity, as I think is happening here. You may need to use twoway kdensity called twice. The Gaussian curves can be superimposed with calls to twoway function.

      Code:
       
      twoway kdensity ... || kdensity ... || function ... || function ...

      Comment

      Working...
      X