繁体   English   中英

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

[英]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
}

就系数而言, 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 

但是你可以看到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.

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