簡體   English   中英

如何在 R 中成功制作帶有圖例的輪廓增強漏斗 plot?

[英]How do I successfully make a contour-enhanced funnel plot with legend in R?

我正在嘗試在 R 中創建一個輪廓增強漏斗 plot 以進行薈萃分析。 輪廓增強的漏斗 plot 還顯示了 plot 對應於不同 p 值的區域(參見 Peters 等人,2008,輪廓增強的薈萃分析漏斗圖有助於區分發表偏倚與其他不對稱原因)。

I found this very useful guide to meta-analytic procedure online ( https://bookdown.org/MathiasHarrer/Doing_Meta_Analysis_in_R/smallstudyeffects.html ) suggesting the following code to create such a plot:

funnel(m.hksj, xlab="Hedges' g", 
       contour = c(.95,.975,.99),
       col.contour=c("darkblue","blue","lightblue"))+
legend(1.4, 0, c("p < 0.05", "p<0.025", "< 0.01"),bty = "n",
       fill=c("darkblue","blue","lightblue"))

執行此代碼時,會生成 plot,但沒有圖例。 該錯誤表示二元運算符有一個非數字參數。 我還確保專門使用meta package 中的funnel() function,正如它在指南中所說的那樣,因為在我的環境中也加載了metafor 有人知道如何解決這個問題並創造一個美好的傳說嗎?

另外,我嘗試了metafor package ( http://www.metafor-project.org/doku.php/plots:contour_enhanced_funnel_plot ) 的創建者建議的以下代碼:

funnel(res, level=c(.90, .95, .99),shade=c("white", "gray55", "gray75"), refline=0, legend=TRUE)

關於level參數有很多警告,它甚至沒有產生工作漏斗 plot,更不用說有圖例了。 在這種情況下,我假設這是由於我提交的不是 rma object,而是來自 meta package 的 meta object。 另一方面,它應該與上面的第一個代碼一起工作,但事實並非如此。

感謝所有建議!

編輯:這是一個基於上述指南中提供的代碼的示例

data = data.frame("Author" = c("Jones", "Goldman", "Townsend", "Martin", "Rose"),
                  "TE" = c(0.23, 0.56, 0.78, 0.23, 0.33),
                  "seTE" = c(0.324, 0.235, 0.394, 0.275, 0.348),
                  "subgroup" = c("one", "one", "two", "two", "three"))

m.data <- metagen(TE,
                  seTE,
                  data = data,
                  studlab = paste(Author),
                  comb.fixed = FALSE,
                  comb.random = TRUE,
                  method.tau = "SJ",
                  hakn = TRUE,
                  prediction = TRUE,
                  sm = "SMD")

funnel(m.data, xlab="Hedges' g", 
       contour = c(.95,.975,.99),
       col.contour=c("darkblue","blue","lightblue"))+
legend(1.4, 0, c("p < 0.05", "p<0.025", "< 0.01"),bty = "n",
       fill=c("darkblue","blue","lightblue"))

由於加號,您收到錯誤,並且圖例未打印,因為坐標可能超出 plot 的范圍。

嘗試刪除加號並更改圖例的坐標,如下所示:

funnel(m.data, xlab="Hedges' g", 
           contour = c(.95,.975,.99),
           col.contour=c("darkblue","blue","lightblue"))
legend("topright", c("p < 0.05", "p<0.025", "< 0.01"),bty = "n",
           fill=c("darkblue","blue","lightblue"))

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM