Cox模型,coxph(),无事件控制处理,种子萌发

问题描述 投票:1回答:1

我正在进行生存分析,我不确定我是否正确地进行了生存分析。我的数据集是种子萌发实验的结果。感兴趣的主要变量是“治疗”(分类为3级)。在我的剧本中,我试图通过比较PH系数百分比来确定治疗之间是否存在差异,哪一个是最好的,哪个程度是最好的。任何人都可以帮我解决我正在处理的一些问题吗?

1)我是否需要声明我的变量as.factor()来使用它们?或者整数被同等解释?

2)如果违反了危险假设(PH)的相称性,我应该如何处理我的数据以进入考克斯模型建立?我已经进行了深入的研究,但却无法理解为我的模型添加协变量*时间交互或分层的编程。

3)如何将脆弱的术语包括在考克斯模型中并检测随机效应(例如种子发芽的板,4级的分类变量,代表重复)。

4)我也无法解释印刷品(摘要(cox.fra))。*

*见下文

请参阅下面我的两个带注释的整个脚本。

脚本1

    rd01 <- read.table("sa_kb01.txt", header = T) # raw dataset, seed 
    survival
    rd01

    str(rd01) 

    rd01$begin <- as.factor(rd01$begin) # integers to factors
    rd01$spp <- as.factor(rd01$spp)
    rd01$cit <- as.factor(rd01$cit)
    rd01$treat <- as.factor(rd01$treat)
    rd01$plate <- as.factor(rd01$plate)

    str(rd01) 

    summary(rd01)

    names(rd01) # headers

    ### Survival analysis

    # install.packages("survival")

    library(survival)
    library (survminer)

    ?survfit
    ?survfit.formula
    ?survfit.coxph
    ?ggsurvplot

    ## Fit Kaplan-Meier survivor function

    km.fit <- survfit(Surv(day, status) ~ treat, data= rd01, type="kaplan-meier")
    km.fit
    print(summary(km.fit))

    plot(km.fit, conf.int= T, fun = "event", mark.time = c(140), pch = c("S", "W", "A"), col = c("darkred","darkblue","darkgreen"), lty = c("solid","dotted","longdash"),lwd = 1.5, xlab = "time [days]", ylab = "germination probability [%]")

    print(summary(km.fit))

    ## Comparison of Survivor Functions

    # Log-rank tests

    ?survdiff

    # Log-rank or Mantel-Haenszel test in "rho = 0" OR 
    # Peto & Peto modification of the Gehan-Wilcoxon test in "rho = 1"
    # ... Assess all groups for heterogeneity
    lrmh.123 <- survdiff(Surv(day,status) ~ treat, data= rd01, rho= 0) 

    print(lrmh.123) # If p<0.05 there are difference between all groups!

    # ... Comparing groups pairwise

    lrmh.120 <- survdiff(Surv(day,status) ~ treat, data= rd01, subset= {treat!=3}, rho= 0)
    lrmh.103 <- survdiff(Surv(day,status) ~ treat, data= rd01, subset= {treat!=2}, rho= 0)
    lrmh.023 <- survdiff(Surv(day,status) ~ treat, data= rd01, subset= {treat!=1}, rho= 0)

    print(lrmh.120)
    print(lrmh.103)
    print(lrmh.023) # If p<0.05 there are difference pairwised groups!

    ## Checking Proportional Hazard (PH) assumption

    # Define function mlogmlog() to calculate -log(-log(S(t)))
    mlogmlog <- function(y){-log(-log(y))}

    # Use estimated Kaplan-Meier survivor functions
    km.fit

    # ... to plot -log(-log(S(t))) versus log(t)
    plot(km.fit, fun= mlogmlog, log="x", mark.time= c(140), pch = c("S", "W", "A"), col = c("darkred","darkblue","darkgreen"), lty = c("solid","dotted","longdash"), lwd = 1.5, xlab="time [days]", ylab= "-log(-log(S(t)))") # If lines do not cross, PH assumption is plausible!

    # Interpretarion: http://www.sthda.com/english/wiki/cox-model-assumptions#testing-proportional-hazards-assumption

    ## Checking for multicollinearity

    # install.packages("HH")
    library(HH)

    # Fit a generalized linear model predicting days from treatment
    ?glm
    mc.glm <- glm(day ~ treat, data=rd01)
    print(mc.glm) # doesn't need interpretation, only used to create object to VIF function

    # Check for multicollinearity among covariates throught variance inflation factor (VIF)
    ?vif
    mc.vif <- vif(mc.glm)
    print(mc.vif) # VIF can determine what proportion of the variation in each covariate 
    # is explained by the other covariates:
    # VIF > 10, serious multicollinearity; VIF = 5, evidence of multicollinearity;
    # VIF < 1, no evidence of multicollinearity

    ## Adding covariates to the Cox model

    # Create a Cox model
    cox.mod <- coxph(Surv(day, status) ~ treat, data= rd01)
    print(summary(cox.mod)) 

    # Interpretation: http://www.sthda.com/english/wiki/cox-proportional-hazards-model

    # Double check for PH assumption now with Cox model built
    dc.ph <- cox.zph(cox.mod)
    dc.ph  
    ggcoxzph(dc.ph) # if global and individual p-vale > 0.05, PH assumption is plausible! 

    ## Including random effects
    ?frailty

    # Adding plate variable as frailty term 
    cox.fra <- coxph(Surv(day, status) ~ treat + frailty(plate), data= rd01)
    print(summary(cox.fra)) # if global and individual p-vale < 0.05, 
    # maintain frailty term while adding covariates 1 at a time in cox model!`

脚本2 - 相同但不同的数据集,控制treat1没有事件!

    rd01 <- read.table("sa_hal01.txt", header = T) # raw dataset, seed         survival
    rd01

    str(rd01) 

    rd01$begin <- as.factor(rd01$begin) # integers to factors
    rd01$spp <- as.factor(rd01$spp)
    rd01$cit <- as.factor(rd01$cit)
    rd01$treat <- as.factor(rd01$treat)
    rd01$plate <- as.factor(rd01$plate)

    str(rd01) 

    summary(rd01)

    names(rd01) # headers

    ### Survival analysis

    # install.packages("survival")

    library(survival)
    library (survminer)

    ?survfit
    ?survfit.formula
    ?survfit.coxph
    ?ggsurvplot

    ## Fit Kaplan-Meier survivor function

    km.fit <- survfit(Surv(day, status) ~ treat, data= rd01, type="kaplan-meier")
    km.fit
    print(summary(km.fit))

    plot(km.fit, conf.int= T, fun = "event", mark.time = c(140), pch = c("S", "W", "A"), col = c("darkred","darkblue","darkgreen"), lty = c("solid","dotted","longdash"),lwd = 1.5, xlab = "time [days]", ylab = "germination probability [%]")

    print(summary(km.fit))

    ## Comparison of Survivor Functions

    # Log-rank tests

    ?survdiff

    # Log-rank or Mantel-Haenszel test in "rho = 0" OR 
    # Peto & Peto modification of the Gehan-Wilcoxon test in "rho = 1"
    # ... Assess all groups for heterogeneity
    lrmh.123 <- survdiff(Surv(day,status) ~ treat, data= rd01, rho= 0) 

    print(lrmh.123) # If p<0.05 there are difference between all groups!

    # ... Comparing groups pairwise

    lrmh.120 <- survdiff(Surv(day,status) ~ treat, data= rd01, subset= {treat!=3}, rho= 0)
    lrmh.103 <- survdiff(Surv(day,status) ~ treat, data= rd01, subset= {treat!=2}, rho= 0)
    lrmh.023 <- survdiff(Surv(day,status) ~ treat, data= rd01, subset=         {treat!=1}, rho= 0)

    print(lrmh.120)
    print(lrmh.103)
    print(lrmh.023) # If p<0.05 there are difference pairwised groups!

    ## Checking Proportional Hazard (PH) assumption

    # Define function mlogmlog() to calculate -log(-log(S(t)))
    mlogmlog <- function(y){-log(-log(y))}

    # Use estimated Kaplan-Meier survivor functions
    km.fit

    # ... to plot -log(-log(S(t))) versus log(t)
    plot(km.fit, fun= mlogmlog, log="x", mark.time= c(140), pch =         c("S", "W", "A"), col = c("darkred","darkblue","darkgreen"), lty =         c("solid","dotted","longdash"), lwd = 1.5, xlab="time [days]", ylab= "-        log(-log(S(t)))") # If lines do not cross, PH assumption is plausible!

    # Interpretarion: http://www.sthda.com/english/wiki/cox-model-        assumptions#testing-proportional-hazards-assumption

    ## Checking for multicollinearity

    # install.packages("HH")
    library(HH)

    # Fit a generalized linear model predicting days from treatment
    ?glm
    mc.glm <- glm(day ~ treat, data=rd01)
    print(mc.glm) # doesn't need interpretation, only used to create object to         VIF function

    # Check for multicollinearity among covariates throught variance inflation         factor (VIF)
    ?vif
    mc.vif <- vif(mc.glm)
    print(mc.vif) # VIF can determine what proportion of the variation in each covariate 
    # is explained by the other covariates:
    # VIF > 10, serious multicollinearity; VIF = 5, evidence of                 multicollinearity;
    # VIF < 1, no evidence of multicollinearity

    ## Adding covariates to the Cox model

    # Create a Cox model
    cox.mod <- coxph(Surv(day, status) ~ treat, data= rd01)
    print(summary(cox.mod)) 

    # Interpretation: http://www.sthda.com/english/wiki/cox-proportional-hazards-model

    # Double check for PH assumption now with Cox model built
    dc.ph <- cox.zph(cox.mod)
    dc.ph  
    ggcoxzph(dc.ph) # if global and individual p-vale > 0.05, PH assumption is                         plausible! 

    ## Including random effects
    ?frailty

    # Adding plate variable as frailty term 
    cox.fra <- coxph(Surv(day, status) ~ treat + frailty(plate), data=                 rd01)
    print(summary(cox.fra)) # if global and individual p-vale < 0.05, 
    # maintain frailty term while adding covariates 1 at a time in cox model!

似乎存在统计上显着的差异,并且treat3与两个脚本中的其他组不同。在脚本1中PH被违反,我现在不做该做什么。除此之外,脚本1中的Cox模型似乎工作正常并且风险比的解释是可以的,但在脚本2中,不知道如何解释或解决(控制条件1中没有事件)。

r survival-analysis cox-regression
1个回答
0
投票

1)我是否需要声明我的变量as.factor()来使用它们?或者整数被同等解释?

我认为在你的情况下as.factor是正确的。如果你有连续的数字变量,你可以使用整数 - 例如,如果你在实验之前有时间存储种子,你可以使用as.numeric作为时间变量。

2)如果PH被违反,我应该如何处理我的数据以进入考克斯模型建设?我已经进行了深入的研究,但却无法理解为我的模型添加协变量x时间交互或分层的编程。

Cox回归,即Cox比例风险模型,基于比例风险的假设。如果违反该假设,您将无法获得可靠的结果。您可能可以尝试一些数据转换,看看它是否有帮助。或者,如果在某个子实验/组中违反了它,您可以将其删除。

© www.soinside.com 2019 - 2024. All rights reserved.