Announcement

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

  • Metan: Change p value for test for heterogeneity from p=0.000 to p<0.001

    Hi there,

    I am running a series of meta analyses in a loop to produce forest plots. Code:

    levels VariableName
    foreach i in `r(levels)'{
    metan beta_ se_ if VariableName =="`i'", lcols(month)
    graph save "file_`i'", replace
    }

    However, the p value for the test of heterogeneity appears as p=0.000 and I've been asked for that to be changed to p<0.001.

    I have read a previous thread about this (https://www.statalist.org/forums/for...in-forest-plot) and attempted to adapt the code suggested there but Stata produced the error "variable _EFFECT not found" so I've definitely done something wrong!

    How would I get p=0.000 to display as p<0.001 in this instance?

    I am using Stata 17.

    Many thanks in advance,

    Mel

  • #2
    the display is in the "metan_output.ado" at line 731.

    try changing to this.

    Code:
                            if `pvalue'>0.001 {
                                disp as text "  p = " as res %5.3f `pvalue'
                            }
                            else {
                                disp as text "  p < " as res %5.3f 0.001
                            }

    Comment


    • #3
      Thank you so much for your help George. When I run the code below I get the error: >0.001 invalid name.

      Am I doing something wrong? (sorry am very new to Stata!)

      levels VariableName
      foreach i in `r(levels)'{
      metan beta_ se_ if VariableName =="`i'", lcols(month)
      if `pvalue'>0.001 {
      disp as text " p = " as res %5.3f `pvalue'
      }
      else {
      disp as text " p < " as res %5.3f 0.001
      }
      graph save "file_`i'", replace
      }

      Comment


      • #4
        That code has to be inserted into the ado file. It won’t run within a do like that. You have to change the Metan code.

        Comment


        • #5
          I would approach this problem using gr_edit. The only challenge is to find the precise plot number on the graph, which can be accomplished through manual editing within the graph editor. I would proceed as follows:
          a. run -metan- manually for one of the forest plots.
          b. start the graph editor
          c. start recording
          b. edit the P-value manually
          c. save the graph editing history - the file is a .grec
          d. open the .grec file and check the correct plot number (for instance, plotregion1.plot22).



          Code:
                  clear
                  set obs 10
                  gene a = rbinomial(100,0.4)
                  gene b = rbinomial(100,runiform()*0.3+0.1)
                  gene c = rbinomial(100,0.4)
                  gene d = rbinomial(100,0.4)
                  
                  metan a b c d, or random
                  cap drop p1
                  cap drop p2
                  cap drop i2
                  local p1 = r(p_het)
                  gene p2 = `p1' in 1
                  gene p3 = p2
                  gene i2 = r(i_sq) in 1
                  
                  tostring p2, format(%9.2f) replace force
                  local p2 = p2[1]
                  
                      
                  tostring p3, format(%9.3f) replace force
                  local p3 = p3[1]
                          
                  tostring i2, format(%9.1f) replace force
                  local i2 = i[1]
                  
                  
                  
          
                      if `p1' < 0.001 {
                      gr_edit .plotregion1.plot22.EditCustomLabel, j(01) label(I{superscript:2}=`i2'%,  Cochran's Q test, {it:P} < 0.001)
                      }
                      
                      if `p1' >=0.01 {
                      gr_edit .plotregion1.plot22.EditCustomLabel, j(01) label(I{superscript:2}=`i2'%, Cochran's Q test, {it:P} = `p2')
                      }
                      
                      if `p1' <0.01 & `p1' >= 0.001 {
                      gr_edit .plotregion1.plot22.EditCustomLabel, j(01) label(I{superscript:2}=`i2'%, Cochran's Q test, {it:P} = `p3')
                      }
          Last edited by Tiago Pereira; 22 Apr 2023, 19:12.

          Comment


          • #6
            Yup. If it's just the plot, then edit the graph.

            Comment


            • #7
              Thanks so much George & Tiago. I will have a go at editing the graph!

              Comment


              • #8
                Dear all,
                As the co-author and maintainer of the metan package, I will look at implementing this within the next update.
                Thanks,
                David.

                Comment

                Working...
                X