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

如何修正timereg与riskRegression代码以匹配tidycmprsk竞争风险分析结果?

竞争风险分析结果不一致的问题修正请求

我正在使用{MASS}包中的Melanoma数据集开展竞争风险分析,但在tidycmprsk、timereg和riskRegression三个包中得到的结果不一致。

我已按照教程修改了数据集中的status编码,修改代码如下:

Melanoma <- 
  Melanoma %>% 
  mutate(
    status = as.factor(recode(status, `2` = 0, `1` = 1, `3` = 2))
  )

我尝试的代码均可运行但结果不同,现询问如何修正comp.risk和riskRegression部分的代码,使其结果与crr部分一致:

1. {tidycmprsk}包的crr()函数

crr(Surv(time, status) ~ sex + age, data = Melanoma)

运行结果:

## 
## Variable   Coef    SE      HR     95% CI       p-value    
## sex        0.588   0.272   1.80   1.06, 3.07   0.030      
## age        0.013   0.009   1.01   0.99, 1.03   0.18

2. {timereg}包的comp.risk()函数

fit_comprisk <- comp.risk(Event(time, status, cens.code=0) ~ const(sex) + const(age),
                          data = Melanoma, cause = 1, model = "prop")
summary(fit_comprisk)

运行结果:

## Competing risks Model 
## 
## No test for non-parametric terms
## Parametric terms : 
##                Coef.      SE Robust SE      z P-val lower2.5% upper97.5%
## const(sex) -0.394000 0.20200   0.20200 -1.950 0.051   -0.7900    0.00191
## const(age)  0.000604 0.00557   0.00557  0.108 0.914   -0.0103    0.01150

3. {riskRegression}包的riskRegression()函数

fit_rskreg <- riskRegression(Hist(time, status, cens.code=0) ~ sex + age,
                             data = Melanoma, cause = 1, link = "prop")
fit_rskreg

运行结果:

## Competing risks regression model
## 
## IPCW weights: marginal Kaplan-Meier for the censoring distribution.
## Link: 'cloglog' yielding sub-hazard ratios (Fine & Gray 1999)
## No covariates with time-varying coefficient specified.
## 
## Time constant regression coefficients:
##   Variable Levels Coef Lower Upper Pvalue
## sex        1.94 1.115  3.37 0.0189
## age        1.01 0.991  1.03 0.3306
## 
## 
## Note: The coefficients (Coef) are sub-hazard ratios (Fine & Gray 1999)

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.24 00:05:15