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

  • Plot panel regression results


    I am currently trying to plot earning paths between men and women once having controlled for certain covariates.
    Currently I am using coeplot and so my code is this:

    reg real_earnings hrs_wkd_monthly ugpa i.time_since_educ if female==1 & time_since_educ <90
    eststo g1
    reg real_earnings hrs_wkd_monthly ugpa i.time_since_educ if female==0 & time_since_educ <90
    eststo g2

    coefplot (g1, label("Female")) (g2 , label("Male" )) ///
    , drop(_cons hrs_wkd_monthly ugpa) vertical ci title ("Evolution of real earnings from time left education, controlling for hours worked, experience, ugpa", size(vsmall)) xlabel(1 "2" 11 "12" 23"24" 35"36" 47"48" 59"60" 71 "72" 83"84" ) xtitle("Time since education (in months)") graphregion(color(white)) bgcolor(white)

    I have included a dummy for each month after education (time_since_educ) and therefore can plot an average earning for each gender for each month out of education. However, because they are dummies the first month out of education is omitted and then we compare earnings in each future month to this. As a result I am left with the initial value as normalised to 0 (i.e. the second month out of education most individuals are earning about the same as men).

    To be clear I have attached an image of the graph I am currently plotting. You can see that earnings start at a normalised point and hence do not show the initial gap (this is because in each regression we are comparing to the initial time point). t2.pdf

    I want to be able to see the initial earnings gap (which I know exists in my data of about $700/month).

    I know an alternative would be to create averages for earnings for each gender at each time period and plot this, but this doesnt allow me to control for covariates and also to include the confidence intervals, which is what I am after.

    I hope this is clear and would appreciate any comments!

    Attached Files

  • #2
    It sounds like you want something more like this:

    reg real_earnings i.female##(c.hrs_wkd_monthly c.ugpa i.time_since_educ) if time_since_educ &lt;90
    margins female#time_since_educ

    1. I assume that hrs_wkd_monthly and ugpa are continuous variables. If they are discrete, replace their c. prefixes by i.
    2. For a crystal clear introduction to the -margins- command see the excellent Richard Williams' It includes several worked examples that include interaction models like yours.
    3. -marginsplot- must be run immediately after -margins-. No other commands can intervene, even if those commands do not modify r() or e().
    4. -marginsplot- accepts most -graph twoway- options, so you can customize the graph to your taste.


    • #3
      Thank you Clyde, this works well. The only issue is the margins command takes over 30 minutes to run each time!


      • #4
        Yes, it is very computationally intensive. If you don't need the confidence intervals, you could add the -nose- option. That would cause -margins- to skip calculating standard errors, and in most situations the standard errors are the most time consuming part. If you need the confidence intervals, then I think you just have to be patient, or get a faster machine.