Announcement

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

  • Density Graph for a Dummy and Continuous Variable

    Hello all,

    I was trying to create a density graph to measure unionised worker's density over the complete wage distribution for men and women in my work, but I am unable to create an effective graph. I have tried this code

    Code:
      twoway kdensity union  if female==0 || kdensity union  if female==1,
    by(lnwage) title(Union Density) legend(label(1 "Male") label(2 "Female"))
    but after the code runs I get a graph at every wage value instead of covering the complete distribution. Is there a way where I am able to measure a dummy variable's density over a continuous distribution?

  • #2
    A dummy variable (a.k.a. atttribute or indicator, binary, dichotomous, quantal, logical or Boolean variable) with values ideally 0 and 1 has a density with respect to counting measure but kernel density estimation can't do anything to data for such a variable except smear spikes of counts (proportions, percents) for each value to the kernel shape.

    I guess that what you want is quite different, say

    Code:
     
     twoway kdensity lwage  if union == 1 & female==0 || kdensity lwage  if union == 1 & female==1, legend(label(1 "Male") label(2 "Female"))
    or

    Code:
     
     twoway kdensity lwage  if female==0 || kdensity lwage  if  female==1, legend(label(1 "Male") label(2 "Female")) by(union)

    Comment

    Working...
    X