Announcement

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

  • help with coefplot in loop

    hi everyone,
    apologies if this has been answered already but I am running an OLS loop regression model, something like this:
    forvalues i = 1/12 {
    di "=============================="
    di "Occupation `i' — Unadjusted Job Demands"
    reg MH_trans i.demands_b if occupation_new == `i'
    di "Occupation `i' — Adjusted Job Demands"
    reg MH_trans i.demands_b i.age_cat_10 i.hgsex i.education i.country_birth ///
    i.emparr_4 i.remote_b i.seifa i.HH_structure3 i.long_term_health_cond ///
    if occupation_new == `i'

    }

    I essentially want to draw out the Beta coefficents and the 95% confidence intervals, and create one plot

  • #2
    Consider the following that uses estout and coefplot, both from SSC.

    Code:
    webuse nlswork, clear
    eststo clear
    forval i= 1/4{
        eststo u`i':  regress ln_wage union if occ_code==`i'
        eststo a`i': regress ln_wage union i.race collgrad c.age##c.age msp grade if occ_code==`i'
    }
    
    coefplot (u*, keep(union) label(Unadjusted)) ///
             (a*, keep(union) label(Adjusted)), ///
              aseq swapnames eqrename(u1 a1= "Healthcare" ///
              u2 a2= "Technology" u3 a3= "Finance" u4 a4= "Education") ///
              coeflab(, notick) xline(0) sort
    Res.:

    Click image for larger version

Name:	Graph.png
Views:	1
Size:	30.0 KB
ID:	1782335


    Comment

    Working...
    X