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

使用mice包时weibreg()池化报错,求替代Weibull回归函数

Solution for Weibull Regression with Counting Process Surv in Mice

Hey there! I’ve run into this exact issue before, so let’s break down how to fix it and get your analysis back on track.

Why You’re Seeing That Error

The weibreg() function (from the eha package, I assume) doesn’t have a built-in tidy() method that mice::pool() relies on to aggregate results across imputed datasets. That’s why you’re getting the "No tidy method for objects of class weibreg" error—pool() can’t extract the necessary model coefficients and stats from the weibreg object.

The Best Alternatives

Since your outcome variables (start age, stop age, event) have no missing data, you just need a Weibull model function that works with the counting process Surv() format and plays nicely with mice. Here are two solid options:

1. Use survival::survreg() (Most Recommended)

The survival package is the standard for survival analysis in R, and survreg() fully supports Weibull models and counting process Surv() objects. Even better, mice has native support for survreg models, so pool() will work without issues.

Here’s how to adjust your code:

# Load required packages if you haven't already
library(mice)
library(survival)

# Fit Weibull AFT model across imputed datasets and pool results
mi_reg <- pool(with(mi, survreg(Surv(start_age, end_age, event) ~ x1 + x2 + x3 + x4 + factor(x5), dist = "weibull")))

# View pooled results
summary(mi_reg)
Note on Parameterization

survreg() fits an Accelerated Failure Time (AFT) model by default, whereas weibreg() might fit a proportional hazards (PH) model. To get proportional hazards-style results (like hazard ratios), you can convert the AFT coefficients:

  • The hazard ratio for a covariate is exp(-coef(mi_reg))
  • The Weibull shape parameter can be extracted with 1/mi_reg$pooled$scale

2. Use flexsurv::flexsurvreg() (For More Flexible Parameterization)

If you prefer to fit a direct proportional hazards Weibull model (instead of converting from AFT), the flexsurv package's flexsurvreg() lets you specify parameterization explicitly. It also supports counting process Surv() objects and works with mice (thanks to broom package support for tidy methods).

Example code:

library(flexsurv)

mi_reg <- pool(with(mi, flexsurvreg(Surv(start_age, end_age, event) ~ x1 + x2 + x3 + x4 + factor(x5), dist = "weibull", method = "ph")))

# View pooled PH-style results (hazard ratios directly)
summary(mi_reg)

Key Checks to Confirm

  • Make sure your Surv() syntax is correct: Surv(start_age, end_age, event) is the right format for counting process data in both packages.
  • Since only covariates are missing, your imputation setup (with mice) doesn’t need any changes—just swap out the model fitting function.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.08 11:22:34