我想在x轴下显示生存或累积发生率图中存在风险的数字

时间:2011-08-10 15:47:57

标签: r plot

在x轴标记下,我想注释对应于那些x值的y值。最好由此图解释: Example

1 个答案:

答案 0 :(得分:2)

如果弗兰克哈瑞尔在这里做贡献我会等他发帖,但由于他不是,这里是help(survplot)中他的伟大"中的第一个例子的一个小修改。有效值"包:

require(rms)
n <- 1000
set.seed(731)
age <- 50 + 12*rnorm(n)
label(age) <- "Age"
sex <- factor(sample(c('male','female'), n, TRUE))
cens <- 15*runif(n)
h <- .02*exp(.04*(age-50)+.8*(sex=='female'))
dt <- -log(runif(n))/h
label(dt) <- 'Follow-up Time'
e <- ifelse(dt <= cens,1,0)
dt <- pmin(dt, cens)
units(dt) <- "Year"
dd <- datadist(age, sex)
options(datadist='dd')
S <- Surv(dt,e)

# When age is in the model by itself and we predict at the mean age,
# approximate confidence intervals are ok

survplot(f, age=mean(age), conf.int=.95, 
               n.risk=TRUE, adj.n.risk=.75, y.n.risk=-0.15,
               xlab="")
title(main="Simulated Survival Plot Demonstrating Annotation of N-at-risk")
mtext("Follow-up Years", side=1, line=2)

enter image description here