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

在R中多重插补后,CBPS+WeightThem整合调查权重未生效的问题排查

问题:多重插补后结合CBPS与WeightThem整合调查权重失效

我尝试在R中完成多重插补后,结合CBPS方法与WeightThem工具整合调查/抽样权重,基础代码结构如下:

# MICE多重插补
var_list <- c("outcome", "x1", "x2", "x3", "x4")
tempData_pool <- mice(d2, m = 10, maxit = 20, seed = 100, include = var_list)

# 用WeightThem结合CBPS生成权重
weighted_pool_data <- weightthem(x1 ~ x2 + x3 + x4, 
                  data = tempData_pool, 
                  method = "cbps", 
                  estimand = "ATT") 

# 拟合模型
weighted_pool_model <- with(weighted_pool_data,
                        estimatr::lm_robust(outcome ~ x1 + x2 + x3 + x4))
weighted_pool_results <- pool(weighted_pool_model)

查阅CBPS文档后,我尝试在回归模型中加入调查权重,修改后的代码如下:

weighted_pool_model <- with(weighted_pool_data,
                        estimatr::lm_robust(outcome ~ x1 + x2 + x3 + x4, sample.weight = wgtvar))

weighted_pool_results <- pool(weighted_pool_model)

这段代码没有报错,但模型的系数和标准误完全没有变化,说明调查权重并未实际生效。

我猜测问题出在调查权重变量wgtvar未被纳入插补模型,导致它没有从原始数据框d2传递到weightthem使用的插补数据对象中。

另外,我尝试用survey::svyglm替代lm_robust,理论上代码应该可行,但因为插补后的数据是wimids对象而非普通数据框,无法正常创建调查设计对象:

design <- survey::svydesign(
  ids = ~1, 
  weights = ~wgtvar,
  data = weighted_pool_data)

内容的提问来源于stack exchange,提问作者user14212134

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.27 05:12:32