如何解决将 coxphf 运行到循环函数中并作为单独分析时的不同结果
我正在尝试使用 Firth 惩罚可能性运行 Cox 回归。当我将单变量分析作为单独的分析运行时,我得到的结果与将它运行到一个函数中以应用于多列时的结果不同。总结我的数据:
OS_months <- c(33.6,52.8,7.2,18,80.4,109.2,16.8,108,2.4,51.6,33.6,38.4,12,144,68.4,58.8,142.8,42,8.4,115.2,10.8,103.2,66,141.6,13.2,64.8,20.4,81.6,86.4,105.6,75.6,21.6,201.6,62.4,157.2,170.4,44.4,40.8)
OS_status <- c(0,1,0)
TSPAN6 <- c(0,0)
HR <- data.frame(OS_months,OS_status,TSPAN6)
将分析作为单独的分析运行。
fit=coxphf(Surv(OS_months,OS_status)~TSPAN6,data=HR)
fit
结果
coxphf(formula = Surv(OS_months,OS_status) ~ TSPAN6,data = HR)
Model fitted by Penalized ML
Confidence intervals and p-values by Profile Likelihood
coef se(coef) exp(coef) lower 0.95 upper 0.95 Chisq p
TSPAN6 1.801352 1.051748 6.057834 1.078865 62.16828 4.200166 0.04042002
Likelihood ratio test=4.200166 on 1 df,p=0.04042002,n=50
现在进入创建的函数。
gene<-function(x){
fit=coxphf(Surv(OS_months,OS_status)~x,data=HR)
}
a<-lapply(HR[3],FUN=gene)
a
现在的结果是:
$TSPAN6
coxphf(formula = Surv(OS_months,OS_status) ~ x,data = HR)
Model fitted by Penalized ML
Confidence intervals and p-values by Profile Likelihood
coef se(coef) exp(coef) lower 0.95 upper 0.95 Chisq p
x 0.7413234 0.9106665 2.098711 0.4052701 12.6725 0.8079772 0.368719
Likelihood ratio test=0.8079772 on 1 df,p=0.368719,n=50
你能告诉我这里发生了什么吗?我会非常感谢你。
解决方法
我也是这个领域的新手,我尝试了你的代码。我认为问题发生在原始数据集中,而不是循环运行。由于
1) coxphf(formula = Surv(OS_months,OS_status) ~ TSPAN6,data = HR)
和
2) coxphf(formula = Surv(OS_months,OS_status) ~ HR$TSPAN6,data = HR)
给出不同的结果。 2) 返回与循环结果相同的结果。
另外,我尝试了 coxphf() 提供的示例数据:
time<-c(1,2,3,4)
cens<-c(1,1,0)
x<-c(1,1)
sim<-cbind(time,cens,x)
sim<-data.frame(sim)
coxphf(sim,formula=Surv(time,cens)~x)
gene <- function(var){
+ fit=coxphf(Surv(time,cens)~var,data=sim)
+ return(fit)
+ }
gene(var=x)
返回结果如下:
coxphf(formula = Surv(time,cens) ~ x,data = sim)
Model fitted by Penalized ML
Confidence intervals and p-values by Profile Likelihood
coef se(coef) exp(coef) lower 0.95 upper 0.95 Chisq p
x -0.05065785 1.223583 0.9506039 0.1182198 10.9519 0.002226143 0.9623682
Likelihood ratio test=0.002226143 on 1 df,p=0.9623682,n=4
coxphf(formula = Surv(time,cens) ~ var,data = sim)
Model fitted by Penalized ML
Confidence intervals and p-values by Profile Likelihood
coef se(coef) exp(coef) lower 0.95 upper 0.95 Chisq p
var -0.05065785 1.223583 0.9506039 0.1182198 10.9519 0.002226143 0.9623682
Likelihood ratio test=0.002226143 on 1 df,n=4
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。