[英]In Survival Analysis with R, what is the purpose of the `surv`function in the Cox Proportional Hazards Model?
[英]What is the difference between the coxph and cph functions for calculating Cox's proportional hazards model?
我试图通过生存分析来分析数据集( veteran
,R中的包survival
)。 我在包rms
找到了函数cph
,它看起来和coxph
不同。 这两个功能有什么区别?
此外,在此示例中,
model1<-cph(with(data=veteran,Surv(time,status)~rcs(age,4)+trt),x=TRUE,y=TRUE)
rcs(age,4)
是什么意思?
谢谢你的帮助。
RCS =受限三次样条。 你可以通过查看help(package="rms")
找到函数的帮助文件help(package="rms")
这里是源代码的摘录,所以你可以看到cph
函数调用coxph.fit
函数的位置( survival
包中coxph
的内容)
>cph
[...]
if (nullmod)
f = NULL
else {
ytype = attr(Y, "type")
fitter = if (method == "breslow" || method == "efron") {
if (ytype == "right")
coxph.fit
else if (ytype == "counting")
survival:::agreg.fit
else stop(paste("Cox model doesn't support \"", ytype,
"\" survival data", sep = ""))
}
else if (method == "exact")
survival:::agexact.fit
[...]
class(f) = c("cph", "rms", "coxph")
f
}
就系数而言, cph
和coxph
给出相同的结果:
>library("survival")
>library("rms")
>
>x = rbinom(100, 1,.5)
>t = rweibull(100, 1, 1)
>
>m1 = coxph(Surv(t)~x)
>m2 = cph(Surv(t)~x)
>m1$coefficients
x
0.2226732
>m2$coefficients
x
0.2226732
但是你可以看到cph
函数的作者在结果中添加了一些额外的组件以满足他们的需求。 因此,如果您需要其中一个额外功能, cph
将非常有用,否则, coxph
会做得很好。
>attributes(m1)
$names
[1] "coefficients" "var" "loglik" "score"
[5] "iter" "linear.predictors" "residuals" "means"
[9] "concordance" "method" "n" "nevent"
[13] "terms" "assign" "wald.test" "y"
[17] "formula" "call"
$class
[1] "coxph"
>attributes(m2)
$names
[1] "coefficients" "var" "loglik" "score"
[5] "iter" "linear.predictors" "residuals" "means"
[9] "concordance" "terms" "n" "call"
[13] "Design" "assign" "na.action" "fail"
[17] "non.slopes" "stats" "method" "maxtime"
[21] "time.inc" "units" "center" "scale.pred"
$class
[1] "cph" "rms" "coxph"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.