简体   繁体   English

用于计算Cox比例风险模型的coxph和cph函数有什么区别?

[英]What is the difference between the coxph and cph functions for calculating Cox's proportional hazards model?

I am trying to analyse a dataset ( veteran , in package survival in R) with survival analysis. 我试图通过生存分析来分析数据集( veteran ,R中的包survival )。 I found the function cph in package rms , which seems like different to coxph . 我在包rms找到了函数cph ,它看起来和coxph不同。 What is the difference between these two functions? 这两个功能有什么区别?

Also, in this example, 此外,在此示例中,

model1<-cph(with(data=veteran,Surv(time,status)~rcs(age,4)+trt),x=TRUE,y=TRUE)

what's does rcs(age,4) mean? rcs(age,4)是什么意思?

Thanks for your help. 谢谢你的帮助。

RCS = restricted cubic spline. RCS =受限三次样条。 You can find the function's help file by looking at help(package="rms") 你可以通过查看help(package="rms")找到函数的帮助文件help(package="rms")

Here's an excerpt of the source code, so you can see where the cph function calls the coxph.fit function (the guts of coxph in the survival package) 这里是源代码的摘录,所以你可以看到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
}

Both cph and coxph give the same results as far as coefficients: 就系数而言, cphcoxph给出相同的结果:


>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 

But you can see that the authors of the cph function have added some extra components to the results to fit their needs. 但是你可以看到cph函数的作者在结果中添加了一些额外的组件以满足他们的需求。 Thus cph will be useful if you need one of those extra features, but otherwise, coxph will do just fine. 因此,如果您需要其中一个额外功能, 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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM