3

我的目标是模拟一个可用于测试竞争风险模型的数据集。我只是尝试使用该survsim::crisk.sim函数的一个简单示例,但它不会导致我期望的结果。

 require(survival)
 simulated_data <- survsim::crisk.sim(n = 100,
                                      foltime = 200,
                                      dist.ev = rep("weibull", 2),
                                      anc.ev = c(0.8, 0.9),
                                      beta0.ev = c(2, 4),
                                      anc.cens = 1,
                                      beta0.cens = 5,
                                      nsit = 2)

 model <- survreg(Surv(time, status) ~ 1 + strata(cause), data = simulated_data)

 exp(model$scale)

 ## cause=1  cause=2 
 ## 4.407839 2.576357 

我希望这些数字与beta0.ev. 任何指向我可能做错的地方或其他如何模拟竞争风险数据的建议。

为了完成:我希望模拟数据中的事件遵循每个风险不同的 Weibull 分布。我希望能够在数据中指定一个层次和集群。审查可以遵循 Weibull 或 Bernouli 分布。

4

1 回答 1

1

要恢复指定的估计值,您可以使用survreg特定原因的表示法。

此示例使用您的参数,但需要更多患者进行更精确的估计:

set.seed(101)
stack_data <- survsim::crisk.sim(n = 2000,
                                     foltime = 200,
                                     dist.ev = rep("weibull", 2),
                                     anc.ev = c(0.8, 0.9),
                                     beta0.ev = c(2, 4),
                                     anc.cens = 1,
                                     beta0.cens = 5,
                                     nsit = 2)

m1 <- survreg(Surv(time, cause==1) ~ 1, data =stack_data, dist = "weibull")
m2 <- survreg(Surv(time, cause==2) ~ 1, data = stack_data, dist = "weibull")

m1$coefficients This will approach beta0.ev for cause 1

m2$coefficients This will approach beta0.ev for cause 2

> m1$coefficients
(Intercept) 
   1.976449 
> m2$coefficients
(Intercept) 
   3.995716 

m1$scale This will approach anc.ev for cause 1

m2$scale This will approach anc.ev for cause 2

> m1$scale
[1] 0.8088574
> m2$scale
[1] 0.8923334

Unfortunately this only holds with uniform censoring, or low non-uniform censoring (such as in your example)

If we increase the hazard of censoring then the intercepts do not represent the beta0.ev parameters

set.seed(101)
stack_data <- survsim::crisk.sim(n = 2000,
                                     foltime = 200,
                                     dist.ev = rep("weibull", 2),
                                     anc.ev = c(0.8, 0.9),
                                     beta0.ev = c(2, 4),
                                     anc.cens = 1,
                                     beta0.cens = 2, #reduced from 5, increasing the hazard function for censoring rate
                                     nsit = 2)

m1 <- survreg(Surv(time, cause==1) ~ 1, data =stack_data, dist = "weibull")
m2 <- survreg(Surv(time, cause==2) ~ 1, data = stack_data, dist = "weibull")

> m1$coefficients
(Intercept) 
   1.531818 
> m2$coefficients
(Intercept) 
   3.553687 
> 
> m1$scale
[1] 0.8139497
> m2$scale
[1] 0.8910465
于 2020-03-04T11:27:00.087 回答