Announcement

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

  • Creating a graph with hours worked and wage

    Hello all,

    Let's say I have two variables - weekly hours worked (hourly_work) and hourly wage (hourly_wage).

    What I'd like to do is plot the mean hours of work by wage level (basically across all wage levels), with mean hours of work on the y-axis and hourly wage on the axis.

    What I'm struggling with is creating a mean variable for each wage level - of course there an infinite number of wage levels and sometimes the mean of a wage level will be a sample of one. But that is not my concern. I can create a mean with a group but not sure how to do it on an individual level.

    Thanks

  • #2
    Code:
    // open example data
    sysuse nlsw88, clear
    
    // group wage in 10 deciles
    xtile wage_gr = wage, nq(10)
    
    // for plotting assign them the middle wage
    bys wage_gr (wage) : replace wage_gr = (wage[_N] - wage[1])/2 + wage[1]
    
    // create mean hours per wage group
    bys wage_gr : egen hours_m = mean(hours)
    
    // plot the two variables
    twoway scatter hours_m wage_gr
    ---------------------------------
    Maarten L. Buis
    University of Konstanz
    Department of history and sociology
    box 40
    78457 Konstanz
    Germany
    http://www.maartenbuis.nl
    ---------------------------------

    Comment


    • #3
      Maarten's advice is always good, but I don't quite share his enthusiasm for decile bins.

      But additionally I'd use a scatter plot smoother. If your dataset is moderate or large in size, expect results to be a little slow.

      I have struggled often to move away from lpoly's defaults but you may want to try mine!

      See http://www.statalist.org/forums/foru...ial-regression

      Comment

      Working...
      X