Announcement

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

  • Misuse of forestplot

    Hi
    In many cases, I use the following code:
    Code:
    cls
    webuse lbw, clear
    regress bwt i.smoke##i.race
    margins smoke#race
    mata st_matrix("tbl", st_matrix("r(table)")[(1,5,6,4), .]')
    matrix roweq tbl = non-smoker non-smoker non-smoker smoker smoker smoker
    matrix rownames tbl = white black other white black other
    matrix colnames tbl = b lb ub p
    matrix2stata tbl, clear
    rename tbl_* * 
    strofnum eq names
    meta set b lb ub, studylabel(names) random(mle)
    meta forestplot _id _plot _esci, subgroup(eq) note("") nogmarkers noomarker ///
      noohetstats noohomtest noosigtest noghetstats nogwhomtests nogbhomtests ///
      columnopts(_id, title("")) columnopts(_esci, supertitle("mean weight")) /// 
      nooverall name(fig2, replace) nullrefline
    to get a nice graph like:
    Click image for larger version

Name:	g1.png
Views:	1
Size:	70.2 KB
ID:	1658557
    What I can't figure out is the option to remove the summary rows (red dot in front) from the graph.
    Does anyone know?

    Thank you very much in advance.
    Kind regards

    nhb

  • #2
    Niels, hi.

    I would not use the random-effects ML weights. I would simply use the same weight for all estimates.



    Code:
    use http://www.stata-press.com/data/r10/lbw.dta, clear
    regress bwt i.smoke##i.race
    margins smoke#race
    mata st_matrix("tbl", st_matrix("r(table)")[(1,5,6,4), .]')
    matrix roweq tbl = non-smoker non-smoker non-smoker smoker smoker smoker
    matrix rownames tbl = white black other white black other
    matrix colnames tbl = b lb ub p
    matrix2stata tbl, clear
    rename tbl_* *
    strofnum eq names
    meta set b lb ub, studylabel(names) random(mle)
    meta forestplot _id _plot _esci, subgroup(eq) note("") nogmarkers noomarker ///
      noohetstats noohomtest noosigtest noghetstats nogwhomtests nogbhomtests ///
      columnopts(_id, title("")) columnopts(_esci, supertitle("mean weight")) ///
       name(fig2, replace) nullrefline nometashow   overallopts(size(0))         
       
     
     forvalues i = 1/2 {
       
       
        gr_edit .plotregion1.column5.group_items[`i'].draw_view.setstyle, style(no)
        gr_edit .set_spositions
        gr_edit .set_graphwidth
    
    
        gr_edit .plotregion1.column6.group_items[`i'].draw_view.setstyle, style(no)
        gr_edit .set_spositions
        gr_edit .set_graphwidth
        
    
        gr_edit .plotregion1.column7.group_items[`i'].draw_view.setstyle, style(no)
        gr_edit .set_spositions
        gr_edit .set_graphwidth
    
    }

    Comment


    • #3
      Dear Tiago Thank you very much.
      I had hoped that I could have avoided the use of gr_edit

      Kind regards

      nhb

      Comment


      • #4
        Originally posted by Niels Henrik Bruun View Post
        What I can't figure out is the option to remove the summary rows (red dot in front) from the graph.
        Does anyone know?
        Those are controlled by the -groupopts()- option.

        Code:
        webuse lbw, clear
        regress bwt i.smoke##i.race
        margins smoke#race
        mata st_matrix("tbl", st_matrix("r(table)")[(1,5,6,4), .]')
        matrix roweq tbl = non-smoker non-smoker non-smoker smoker smoker smoker
        matrix rownames tbl = white black other white black other
        matrix colnames tbl = b lb ub p
        matrix2stata tbl, clear
        rename tbl_* * 
        strofnum eq names
        meta set b lb ub, studylabel(names) random(mle)
        meta forestplot _id _plot _esci, subgroup(eq) note("") nogmarkers noomarker ///
          noohetstats noohomtest noosigtest noghetstats nogwhomtests nogbhomtests ///
          columnopts(_id, title("")) columnopts(_esci, supertitle("mean weight")) /// 
          nooverall name(fig2, replace) groupopts(color(none)) nullrefline

        Click image for larger version

Name:	fig2.png
Views:	1
Size:	40.9 KB
ID:	1658654

        Comment


        • #5
          Excellent, thank you very much
          But hey, then I loose the subgroup titles as well?
          Last edited by Niels Henrik Bruun; 08 Apr 2022, 06:16.
          Kind regards

          nhb

          Comment


          • #6
            Yes, they are rendered together. I see no option to specify each separately.

            Comment


            • #7
              Ok thank you
              Kind regards

              nhb

              Comment


              • #8
                Just for interest's sake, here is one way to achieve a similar result using the user-contributed command metan (latest version v4.05 via SSC):

                Code:
                webuse lbw, clear
                regress bwt i.smoke##i.race
                margins smoke#race
                mata: st_matrix("tbl", st_matrix("r(table)")[(1,5,6,4), .]')
                matrix colnames tbl = b lb ub p
                  
                keep smoke race
                duplicates drop
                sort smoke race
                svmat tbl, names(col)
                
                metan b lb ub, study(race) by(smoke) effect(Mean weight) re(ml) nohet nowt nooverall nograph clear
                label variable _LABELS ""
                replace _LABELS = "" if _USE==3
                replace _LABELS = "{tab}" + _LABELS if _USE==1
                forestplot, useopts nonote nonull xlabel(2000(500)3500) range(2000 3633) ///
                        olineopts(lcolor(none) lwidth(none)) diamopts(lcolor(none) lwidth(none)) ///
                        classic boxsca(200)
                Last edited by David Fisher; 08 Apr 2022, 10:41.

                Comment


                • #9
                  David Fisher Nice
                  Kind regards

                  nhb

                  Comment

                  Working...
                  X