[英]R survival package; plotting log(-log(survival)) against log(time)
I'm trying to use the R survival package, to produce a plot of log(-log(survival))
against log(time)我正在尝试使用 R 生存包,生成
log(-log(survival))
对 log(time) 的图
(This is something sometimes recommended as a way to visually inspect for accelerated lifetime or proportional hazard properties). (有时建议将这种方法用作目视检查加速寿命或成比例危险特性的方法)。
The " fun=cloglog
" option in plot.survfit
is not producing what I expect it to.在“
fun=cloglog
”在选项plot.survfit
不生产什么,我期望它。
Using the "gehan" data from the "MASS" library:使用“MASS”库中的“gehan”数据:
first, here is a simple plot of survival against time, for the treatment and control groups:首先,这是治疗组和对照组的简单生存时间图:
data(gehan, package="MASS")
gehansurv=Surv(gehan$time, gehan$cens)
plot(survfit(gehansurv ~ gehan$treat), col=c("black", "red"))
OK so far.到此为止。 Now, if I use the
fun=cloglog
option, the documentation for plot.survfit makes me think that I'll get a plot of log(-log(survival))
against log(time)
:现在,如果我使用
fun=cloglog
选项, fun=cloglog
的文档让我觉得我会得到一个log(-log(survival))
对log(time)
:
fun
乐趣
an arbitrary function defining a transformation of the survival curve.
定义生存曲线变换的任意函数。 For example fun=log is an alternative way to draw a log-survival curve (but with the axis labeled with log(S) values), and fun=sqrt would generate a curve on square root scale.
例如, fun=log 是绘制对数生存曲线的另一种方法(但轴标有 log(S) 值),而 fun=sqrt 将生成平方根尺度的曲线。 Four often used transformations can be specified with a character argument instead: "log" is the same as using the log=T option, "event" plots cumulative events (f(y) = 1-y), "cumhaz" plots the cumulative hazard function (f(y) = -log(y)), and "cloglog" creates a complimentary log-log survival plot (f(y) = log(-log(y)) along with log scale for the x-axis).
可以使用字符参数指定四种常用的转换:“log”与使用 log=T 选项相同,“event”绘制累积事件 (f(y) = 1-y),“cumhaz”绘制累积事件风险函数 (f(y) = -log(y)) 和“cloglog”创建一个免费的对数生存图 (f(y) = log(-log(y)) 以及 x 轴的对数刻度)。
However, when I try this, it doesn't seem to use the log(-log(y))
function, because the displayed curve is still decreasing (since the original survival curve is decreasing, and the applied f(y)=log(-log(y))
function is a decreasing function, the resulting log(-log(survival))
curve should be increasing).但是,当我尝试这个时,它似乎没有使用
log(-log(y))
函数,因为显示的曲线仍在减少(因为原始生存曲线正在减少,并且应用了f(y)=log(-log(y))
函数是一个递减函数,由此产生的log(-log(survival))
曲线应该是递增的)。
Also, the x-axis is not log-scaled:此外,x 轴不是对数缩放的:
library(VGAM)
plot(survfit(gehansurv ~ gehan$treat), col=c("black", "red"), fun=cloglog)
I can get what I want by defining my own log(-log())
function and using the log="x"
option:我可以通过定义我自己的
log(-log())
函数并使用log="x"
选项来获得我想要的:
> myfun=function(p){return(log(-log(p)))}
> plot(survfit(gehansurv ~ gehan$treat), col=c("black", "red"), fun=myfun, log="x")
So: What am I doing wrong above (or how am I misinterpreting the plot.survfit
documentation)?所以:我在上面做错了什么(或者我是如何误解
plot.survfit
文档的)?
Supplementary question: how would a "fun="
option change the scaling on the horizontal axis as the documentation claims that "fun=cloglog"
would, when on the face of it the argument to "fun"
is a function applied to the vertical variable?补充问题:
"fun="
选项如何更改水平轴上的缩放比例,因为文档声称"fun=cloglog"
会,从表面"fun=cloglog"
, "fun"
的参数是应用于垂直变量的函数?
Put quotes around cloglog for plot.survfit.为 plot.survfit 在 cloglog 周围加上引号。
library(survival)
library(MASS)
data(gehan)
gehansurv=Surv(gehan$time, gehan$cens)
plot(survfit(gehansurv ~ gehan$treat), col=c("black", "red"), fun="cloglog")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.