You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在meta包森林图中隐藏Overall行的固定与随机效应权重?

森林图隐藏「Overall」行权重的解决方案

问题说明

需要在meta分析森林图中仅隐藏「Overall」行的固定效应(common)和随机效应(random)权重,直接修改meta对象的w.common/w.random为NA会触发forest函数的参数类型错误。

可行实现方法

通过在forest()函数中传入自定义权重显示向量来实现,具体步骤如下:

  1. 定位「Overall」行的索引:
overall_idx <- which(meta_MCM_brut$studlab == "Overall")
  1. 创建自定义权重向量,将「Overall」行的权重设为NA(NA值会被forest函数自动隐藏):
# 处理固定效应权重
w_common_custom <- meta_MCM_brut$w.common
w_common_custom[overall_idx] <- NA

# 处理随机效应权重
w_random_custom <- meta_MCM_brut$w.random
w_random_custom[overall_idx] <- NA
  1. 修改原forest()调用,加入自定义权重参数:
forest(meta_MCM_brut, fontsize = 8, text.fixed = "Fixed-effect model",
       text.random = "Random-effect model",
       leftcols = c("studlab", "exp", "control.nb"),
       leftlabs = c("Study", paste("Exposed", "\n", "(events/total)"), paste("Unexposed", "\n", "(events/total)")),
       prediction = TRUE, rightlabs = c("OR", "95%-CI", "Weight (fixed)", "Weight(random)"),
       text.addline1= 'CI : Confidence Interval, OR : Odds Ratio',
       header.line = 'below', addrows.below.overall = 1,plotwidth = "7cm", just = "center", print.Q = TRUE,
       w.common = w_common_custom,  # 指定固定效应权重显示规则
       w.random = w_random_custom   # 指定随机效应权重显示规则
)

原理说明

forest函数的w.common和w.random参数支持传入自定义向量:

  • 向量长度需与meta对象的行数一致
  • 设定为NA的位置,对应行的权重会被隐藏
  • 无需修改原meta对象的结构,避免参数类型错误

内容的提问来源于stack exchange,提问作者Dark-k

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.15 13:05:36