Announcement

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

  • Editing headings on metan forest plots

    Hi everyone,

    I am making a forest plot using the metan command and I'd like to making the headings and subheadings bold. Is there a way to code this? I tried looking through the manual and tried using graph editor and couldn't find the solution.

    The code I am using is here:

    metan Tdeaths Talive Pdeath Palive, rr fixedi second(random) by(gender) lcols (studyname year allocation) boxsca(80) xlabel(0.4, 2)



    I'd really like to make the headings (Study name, Year of publication, Allocation concealment, RR, and % weight) as well as subheadings (female, male) bold. Thanks so much for your help!
    Attached Files
    Last edited by Eustina Kwon; 19 Nov 2018, 07:08.

  • #2
    Hi Eustina,

    I'm not sure if that is possible using metan. However, here is one way of doing it with admetan, a more up-to-date meta-analysis command (type: ssc describe admetan):

    (N.B. I've copied the data directly from your forest plot, so decimal places etc. might be slightly off.)

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input str6 study long sex int year long alloc float(rr rrlci rruci)
    "study1" 0 1985 1  .74 .52 1.05
    "study2" 0 1992 1   .7 .48 1.01
    "study3" 1 1997 3  .82 .51 1.34
    "study4" 0 2002 2  .83 .65 1.05
    "study5" 1 2000 2  .82 .59 1.13
    "study6" 1 1994 1 1.12 .94 1.33
    end
    label values sex sex
    label def sex 0 "female", modify
    label def sex 1 "male", modify
    label values alloc alloc
    label def alloc 1 "A", modify
    label def alloc 2 "I", modify
    label def alloc 3 "U", modify
    label var study "Study Name"
    label var year "Year of Publication"
    label var alloc "Allocation concealment"

    Run the meta-analysis and save the "forest plot results set":
    Code:
    gen logrr=ln(rr)
    gen logrrlci=ln(rrlci)
    gen logrruci=ln(rruci)
    admetan logrr logrrlci logrruci, rr lcols(study year alloc) by(sex) forest(hetstat(p) leftj) saving(ekwon) nograph

    Load and edit the data (using SMCL for the bold font; see help smcl) then run the forestplot command:
    Code:
    use ekwon, clear
    label var _LABELS `"`"{bf:Study}"' `"{bf:Name}"'"'
    replace _LABELS = `"{bf:"' + _LABELS + `"}"' if _USE==0
    
    label var year `"`"{bf:Year of}"' `"{bf:publication}"'"'
    label var alloc `"`"{bf:Allocation}"' `"{bf:concealment}"'"'
    label var _EFFECT `"{bf:RR (95% CI)}"'
    label var _WT `"`"{bf:%}"' `"{bf:Weight}"'"'
    
    forestplot, useopts nostats nowt rcols(_EFFECT _WT)

    I hope that helps!

    Best wishes,

    David.

    Comment


    • #3
      Thank you, David! I have to edit some of the lines (i.e. stata didn't recognize _EFFECT), but it worked to make the headings/subheadings bold. Thanks for the quick reply!

      Comment


      • #4
        Hi Eustina,

        If Stata didn't recognise _EFFECT, it might be because you are using an outdated version of admetan. Could you check, by typing: which admetan ? It should say "version 3.0".

        I think that, if _EFFECT is not present in the saved dataset, and/or if you are unable to update to v3.0, a longer workaround will be necessary. But I'm glad you got everything else working.

        Thanks,

        David.

        Comment


        • #5
          Ohh gotcha. I downloaded the most recent version of admetan and it worked perfectly. Thank you SO much!

          Comment


          • #6
            Hi David Fisher,

            Thanks so much for all your help so far; is there any way to make the "I-V Subtotal" and the corresponding rows bold as well?

            Comment


            • #7
              Dear Eustina,

              Yes, of course: in fact you've almost done it already.

              Recall the code:
              Code:
              use ekwon, clear
              label var _LABELS `"`"{bf:Study}"' `"{bf:Name}"'"'
              replace _LABELS = `"{bf:"' + _LABELS + `"}"' if _USE==0
              The last line here adds SMCL bold-face tags to the contents of _LABELS when _USE==0. This corresponds to subgroup headings (male, female).
              So, to do the same for any other lines of text within _LABELS, you just need to know how to identify them.

              By default, subgroup headings are identified by _USE==3, and overall headings by _USE==5. (and heterogeneity-related text is _USE==4) Hence, to make the subgroup rows bold:

              Code:
              use ekwon, clear
              label var _LABELS `"`"{bf:Study}"' `"{bf:Name}"'"'
              replace _LABELS = `"{bf:"' + _LABELS + `"}"' if _USE==0
              replace _LABELS = `"{bf:"' + _LABELS + `"}"' if _USE==3
              ...and similarly for any other headings or lines of text.

              Best wishes,

              David.


              P.S. and if you also want the RR values to be in bold, you'd do the same but with the _EFFECT variable.
              Last edited by David Fisher; 27 Nov 2018, 03:30.

              Comment


              • #8
                Dear David Fisher

                First of all, thank you for the above description. It has been very helpfull.

                I do have an issue, however. When I type you command to make the subgroups (sex in your example) bold, my subgroups are all names "_LABELS". Can you help me?

                SYNTAX:

                label values subgroup subgroup
                label define subgroup 0 "Overall", modify
                label define subgroup 1 "BMI", modify

                metan hr lci uci, by(subgroup) label(namevar=sef) effect(HR) null(1) nooverall nosubgroup nobox graphregion(color(white)) forestplot(xlabel(0.5 1 2 3 4 5)) scheme(s2mono) saving(testforest)

                use testforest, clear
                label var _LABELS `"`"{bf:Lifestyle and socioeconomic factors}"'"'
                replace _LABELS = `"`"{bf:"' + _LABELS + `"}"'"' if _USE==0
                label var _EFFECT `"{bf:HR (95% CI)}"'

                forestplot, useopts nostats rcols(_EFFECT)






                Kind regards,
                Kasper

                Comment


                • #9
                  Dear David Fisher

                  First of all, thank you for the above description. It has been very helpfull.

                  I do have an issue, however. When I type you command to make the subgroups (sex in your example) bold, my subgroups are all names "_LABELS". Can you help me?

                  SYNTAX:

                  label values subgroup subgroup
                  label define subgroup 0 "Overall", modify
                  label define subgroup 1 "BMI", modify

                  metan hr lci uci, by(subgroup) label(namevar=sef) effect(HR) null(1) nooverall nosubgroup nobox graphregion(color(white)) forestplot(xlabel(0.5 1 2 3 4 5)) scheme(s2mono) saving(testforest)

                  use testforest, clear
                  label var _LABELS `"`"{bf:Lifestyle and socioeconomic factors}"'"'
                  replace _LABELS = `"`"{bf:"' + _LABELS + `"}"'"' if _USE==0
                  label var _EFFECT `"{bf:HR (95% CI)}"'

                  forestplot, useopts nostats rcols(_EFFECT)






                  Kind regards,
                  Kasper

                  Comment


                  • #10
                    The result
                    Attached Files

                    Comment


                    • #11
                      Hi Kasper Bonnesen

                      In your lines of code:
                      Code:
                      . label var _LABELS `"`"{bf:Lifestyle and socioeconomic factors}"'"'
                      . replace _LABELS = `"`"{bf:"' + _LABELS + `"}"'"' if _USE==0
                      you have used doubled compound quotes; that is:
                      Code:
                      `"`" ... "'"'
                      but in the middle of the second line, you have only closed one set of these; that is:
                      Code:
                      `"`"{bf:"'
                      Therefore, the central part "_LABELS" is treated as text, rather than as part of the command. Although I recommended the use of doubled compound quotes to Eustina (as I recall, in order to force line-breaks on the plot), I don't think you need them for your particular use-case. So I would correct your code as follows:
                      Code:
                      label var _LABELS `"{bf:Lifestyle and socioeconomic factors}"'
                      replace _LABELS = `"{bf:"' + _LABELS + `"}"' if _USE==0
                      I hope that makes sense and that it resolves your issue!

                      Best wishes,

                      David.


                      Comment


                      • #12
                        David Fisher

                        Thank you very much!
                        I you don't mind, I have one more question. Is it possible to change the "," separating the lower and upper confidence limit of the estimate to "–" (a figure/en dash)?

                        Kind regards,
                        Kasper

                        Comment

                        Working...
                        X