Announcement

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

  • Forest Plot Aligning Text

    Hello there,

    I'm currently running subgroup analysis for meta-analysis of odds ratios (STATA v16.1). I am having difficulty with the formatting of the forest plot and was hoping to get some advice. As you can see from the plot below, the string data in the column titled "Description of Control" is all out of line, as are the "No.of cases" and "No. of controls" columns (to a lesser degree). The graph editor won't allow me to correct this and I've tried various colopts, columnopts justitifcation commands with no use.

    The code I am currently running is: metan lnor lnloci lnhici if exposure==1, random eform(Odds Ratio) lcols(author yr cases_n controls_n control_type) xlabel(0.4 1 145) xsize(30) ysize(8) graphregion(color(white))



    Any help/ advice would be greatly appreciated,

    Thanks in advance

    Chris
    Attached Files

  • #2
    I can't say for certain as you do not provide a data example. I suspect the column containing descriptions has leading or trailing spaces. You can pass the variable through -strtrim()- to remove leading and trailing spaces and retry your plot.

    Comment


    • #3
      Hi Leonardo, thanks for replying. Please see below. I've tried the strtrim function but was given the following error message: command strtrim is unrecognized r(199);


      Code:
      * Example generated by -dataex-. For more info, type help dataex
      clear
      input str4 study_label str17 author int(yr cases_n) long controls_n str90 control_type byte exposure double(or lo_ci hi_ci) float(lnor lnloci lnhici _ES) double _seES float(_LCI _UCI) double _WT byte _rsample
      "229"  "Rafnsson V, et al" 1998    8     70 "Randomly allocated community controls"                                             1  13.2     2 140.9  2.580217   .6931472    4.94805  2.580217  1.0854544649952598   .6931472    4.94805 2.6237500005913286 1
      "50"   "Calvert GM, et al" 2003 2036  10165 "Death certificates with no sarcoidosis or disease associated with silica exposure" 1  .674  .557  .815 -.3945252 -.58519006 -.20456716 -.3945252  .09709946115698007 -.58519006 -.20456716  25.38065586670087 1
      "168"  "Kucera GP, et al"  2003  303    619 "Sibling with no diagnosis of sarcoidosis"                                          1  1.62   .82  3.18  .4824261 -.19845094  1.1568812  .4824261   .3457543510355352 -.19845094  1.1568812  13.96710712888048 1
      "151"  "Jonsson E, et al"  2019  371 297546 "Swedish Construction Workers Cohort with no sarcoidosis"                           1  1.11   .84  1.44 .10436001  -.1743534   .3646431 .10436001  .13750163827237888  -.1743534   .3646431 23.712742682822476 1
      "E308" "Beijer E, et al"   2020  256     73 "Obstructive Sleep Apnoea Syndrome patients"                                        1  1.38   .46   4.2  .3220835  -.7765288  1.4350846  .3220835   .5641974481449743  -.7765288  1.4350846 7.7092208550014805 1
      "E312" "Graff P, et al"    2020 6740  13480 "Age, gender and geographic residence matched general population"                   1 1.243 1.112 1.389  .2175278   .1061602   .3285841  .2175278 .056741828688382644   .1061602   .3285841 26.606523466003356 1
      end
      label values exposure exp_label
      label def exp_label 1 "Silica", modify
      Many thanks

      Chris

      Comment


      • #4
        I couldn't make something nice in the few minutes I tried with your dataex, but the problem is exacerbated by the length of your control_type variable. I recommend either trimming it down significantly, or placing that information elsewhere.

        Comment


        • #5
          Chris Huntley

          Sorry for the late reply! I don't know if this will still be useful to you, but just in case (and for the benefit of readers with similar issues): Here is one possible set of options which gives a reasonable result:

          Code:
          label var author "Authors"
          label var yr "Year of Publication"
          label var cases_n "No. of cases"
          label var controls_n "No. of controls"
          label var control_type "Description of Control Group"
          format %1s control_type
          metan lnor lnloci lnhici if exposure==1, random eform(Odds Ratio) lcols(author yr cases_n controls_n control_type) forestplot(xlabel(0.4 1 145, force) spacing(4) astext(60) leftjustify)
          Best wishes,
          David.


          Click image for larger version

Name:	Chris Huntley (cropped).png
Views:	1
Size:	32.2 KB
ID:	1650235

          Last edited by David Fisher; 15 Feb 2022, 10:45.

          Comment


          • #6
            Hi David,

            Apologies I have just seen your reply - it was very helpful thank you - I managed a work-round with manual formatting, but will definitely use your approach in future

            BW

            Chris

            Comment

            Working...
            X