Announcement

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

  • Metan command: change display of overall p-value in forest plot?

    Dear all,
    I am using the metan command to do a meta-analysis and to prepare a forest plot for a publication. Now reviewers came back with asking that the overall p-value, which is currently given in the graph "p=0.000" should be changed to "p<0.001". Can I change the code so that the display of the p-value appears as such? I am using Stata 14. Thank you very much in advance.
    Code:
    metan log_effect log_se, random eform lcols(study) xlab(.1,.5,1,2,4) boxsca(60)
    The below screenshot is the lower part of the forest plot:

    Click image for larger version

Name:	metan_pvalue.PNG
Views:	2
Size:	7.5 KB
ID:	1653843

    Best wishes,
    Jennyfer
    Attached Files

  • #2
    Hi Jennyfer,

    Several things to note here. Firstly, from the look of your plots, you are using an older version of metan. Please update to the latest version via SSC (see help adoupdate)

    Next: The p-value you refer to is not the p-value associated with the overall effect. In fact, it is the p-value associated with the Cochran's Q test for heterogeneity -- or, (roughly) equivalently, associated with the I-squared heterogeneity statistic. You can see that your heterogeneity is very large (I-squared =~ 80% , the red line is masking the exact figure) and hence has a small associated p-value.

    With the latest version of metan, it is possible to adjust the display of figures (such as this p-value) in various ways. For example, the following code (based on a freely-available example dataset) shows how to increase the number of decimal places that are displayed:

    Code:
    use http://fmwww.bc.edu/repec/bocode/m/metan_example_data, clear
    gen logOR=ln(OR)
    gen selogOR=(ln(ORuci)-ln(ORlci))/(2*invnormal(.975))
    metan logOR selogOR, random eform lcols(id) hetinfo(isq p %8.6f)
    Unfortunately, there is no simple way to get Stata to automatically make use of the "less than" symbol when reporting p-values. However, the latest version of metan also allows you to freely edit the displayed text prior to creating the plot. Therefore, below is some code (again based on the example dataset) which solves both the "less than" problem and displays p-values for both heterogeneity (to the left) and for overall effect (to the right):

    Code:
    preserve
        metan logOR selogOR, random eform lcols(id) clear nograph forestplot(extraline(yes))
        if `r(p_z)' < 0.001 {
            replace _EFFECT = "p < 0.001" in L
        }
        else {
            replace _EFFECT = "p = " + strofreal(`r(p_z)', "%05.3f") in L
        }
        forestplot, useopts nostats nowt rcols(_EFFECT _WT)
    restore
    As this is a not-infrequently asked question, I will try and make this easier in a future version of metan.

    Hope that helps,

    David.

    (current maintainer of metan package)

    Comment


    • #3
      [deleted due to redundancy with David's response.] I haven't read David's response in detail.
      Last edited by Tiago Pereira; 11 Mar 2022, 07:58.

      Comment


      • #4
        Thanks Tiago. Just to clarify: my solution will retain the heterogeneity p-value on the left-hand side of the plot, while also adding a new p-value on the right-hand side underneath the summary (pooled) effect estimate. But yes, a footnote to clarify for readers would be a good idea in any case.

        Comment


        • #5
          Dear David,

          Thank you so much for this fast and clear reply. This is so helpful.

          Please allow me one follow-up question: Using the code, I get both the p-value for heterogeneity and the overall effect. However, as shown below in the red circles, only the overall p-value is <0.0001. Would you help me adjusting the code so that also the p-value for heterogeneity displays as p<0.0001?
          Thank you so much again!

          Code:
          preserve
              metan log_effect log_se, random eform lcols(study) clear nograph forestplot(extraline(yes))
              if `r(p_z)' < 0.0001 {
                  replace _EFFECT = "p < 0.0001" in L
              }
              else {
                  replace _EFFECT = "p = " + strofreal(`r(p_z)', "%05.2f") in L
              }
              forestplot, useopts nostats nowt rcols(_EFFECT _WT) xlab(.1 .5 1 2 4) boxsca(60)
          restore
          Click image for larger version

Name:	metan_pvalue2.PNG
Views:	1
Size:	4.4 KB
ID:	1653890

          Best wishes
          Jennyfer

          Comment


          • #6
            Hi Jennyfer,

            Try adding the line in bold:

            Code:
            preserve
                metan log_effect log_se, random eform lcols(study) clear nograph forestplot(extraline(yes))
                if `r(p_z)' < 0.0001 {
                    replace _EFFECT = "p < 0.0001" in L
                }
                else {
                    replace _EFFECT = "p = " + strofreal(`r(p_z)', "%05.2f") in L
                }
                replace _LABELS = subinstr(_LABELS, "p = 0.000", "p < 0.001", .) in L
                forestplot, useopts nostats nowt rcols(_EFFECT _WT) xlab(.1 .5 1 2 4) boxsca(60)
            restore
            Best wishes,

            David.

            Comment


            • #7
              Dear David,

              Works perfectly, thank you very much!

              Best wishes
              Jennyfer

              Comment


              • #8
                Dear David,

                thank you for this helpful code. I had a similar problem but need to have the effect sizes in the forest plot with three decimal spaces. The forest plot at the end truncates to two decimal space
                because _EFFECT only has two decimal spaces. Is there a way to change the decimal places for the forest plot?
                Best regards,
                Karla

                Comment

                Working...
                X