我的目标是模拟可用于测试竞争风险的数据集
模型。我只是尝试使用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分布。
答案 0 :(得分: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
,原因1将接近beta0.ev
m2$coefficients
,原因2将接近beta0.ev
> m1$coefficients
(Intercept)
1.976449
> m2$coefficients
(Intercept)
3.995716
m1$scale
这将导致原因1接近anc.ev
m2$scale
,原因2将接近anc.ev
> m1$scale
[1] 0.8088574
> m2$scale
[1] 0.8923334
不幸的是,这仅在统一检查或低非均匀检查(例如您的示例)中才成立
如果我们增加审查的风险,则截取不代表beta0.ev参数
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