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

咨询survsim包simple.surv.sim函数的log-logistic分布参数输入问题

用survsim生成指定scale和shape的log-logistic生存数据

survsim包的simple.surv.sim函数确实没有直接暴露scale和shape参数,但可以通过anc.ev和beta0.ev映射log-logistic分布的两个参数,对应关系如下:

  • anc.ev:对应log-logistic的形状参数k
  • beta0.ev:对应log-logistic的尺度参数theta的自然对数(即log(theta))

你需要生成X ~ LogLogistic(theta=2, k=4)的生存数据,直接代入参数的代码示例如下:

library(survsim)

# 生成1000个样本,随访时间设为100
sim_data <- simple.surv.sim(
  n = 1000, 
  foltime = 100,
  dist.ev = "llogistic",  # 指定事件时间服从log-logistic分布
  anc.ev = 4,             # 形状参数k=4
  beta0.ev = log(2),      # 尺度参数theta=2,对应log(theta)
  dist.cens = "llogistic",# 若需要删失时间也用log-logistic,同理设置参数
  anc.cens = 2,
  beta0.cens = log(5)
)

# 查看生成的数据结构
str(sim_data)

参数验证(可选)

如果想确认生成的数据符合预期,可以用log-logistic的生存函数验证:
log-logistic的生存函数为 ( S(t) = \frac{1}{1 + (t/\theta)^k} ),代入theta=2,k=4时,t=2的生存概率为0.5(即中位数时间为2),可以通过生成数据的中位数验证:

# 提取未删失的事件时间
event_times <- sim_data$time[sim_data$status == 1]
# 计算中位数,结果应接近2
median(event_times)

内容的提问来源于stack exchange,提问作者이정욱

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.29 01:17:41