1. Table of Contents


This project implements the survival analysis and descriptive modelling steps for a two-group right-censored data with time-independent variables using the Cox Proportional Hazards Model with various helpful packages in R. The Kaplan-Meier Survival Curves and Log-Rank Test were applied during the differential analysis of the survival data between groups. All predictors’ prognostic significance were individually and simultaneously evaluated using Univariate and Multivariate Cox Proportional Hazards Models, respectively. The discrimination power of the resulting models were assessed using the Harrel’s Concordance Index. The final prognostic model was internally validated using Bootstrap Validation with Optimism Estimation and evaluated for compliance on all required model assumptions using the appropriate diagnostics. All results were consolidated in a Summary presented at the end of the document.

Survival analysis corresponds to a set of statistical approaches for time-to-event data, where the outcome variable of interest is the time until an event occurs. Descriptive modelling involves the formulation of statistical models to identify patterns and relationships that can be used for statistical inferences given the predictors and response variables. The methods applied in this study (mostly contained in the survival package) attempt to explore the relationship between factors and both the survival time and event outcomes, while evaluating their effects through statistical hypotheses testing.

1.1 Sample Data


The Cancer dataset from the book Supervised Machine Learning was used for this illustrated example.

Preliminary dataset assessment:

[A] 228 Rows (observations composed of advanced lung cancer patients)

[B] 9 Columns (variables)
     [B.1] 1/9 Factor variable = ph.ecog (factor) referring to the ECOG performance score (0=best, 3=worst) which describes the level of functioning of patients in terms of their ability to care for themselves, daily activity, and physical ability.
          [B.1.1] Asymptomatic = ECOG performance score 0 (asymptomatic)
          [B.1.2] Ambulatory = ECOG performance score 1 (symptomatic but completely ambulatory)
          [B.1.3] Bedridden = ECOG performance score 2 (symptomatic but <50% in bed) or ECOG performance score 3 (symptomatic but >50% in bed)
     [B.2] 1/9 Censoring variable = status (factor)
          [B.2.1] 1 = event, patient died before the end of the study
          [B.2.2] 0 = censored or non-event, patient remains alive until the end of the study, lost to follow-up, experiences a different event that makes further follow-up impossible or withdraws before the end of the study
     [B.3] 1/9 Response variables = time (numeric)
          [B.3.1] time = time in days a patient stays alive up to the point of the patient’s death or being censored
     [B.4] 1/9 Covariate variable = age (numeric)
          [B.4.1] age = patient’s age in years during the conduct of the study
     [B.5] 1/9 Covariate variable = sex (factor)
          [B.5.1] sex = patient’s sex at birth
     [B.6] 1/9 Covariate variable = ph.karno (numeric)
          [B.6.1] ph.karno = Karnofsky performance score (bad=0,good=100) rated by physician
     [B.7] 1/9 Covariate variable = pat.karno: (numeric)
          [B.7.1] pat.karno = Karnofsky performance score (bad=0,good=100) rated by physician
     [B.8] 1/9 Covariate variable = meal.cal (numeric)
          [B.8.1] meal.cal = calories consumed at meals
     [B.9] 1/9 Covariate variable = wt.loss (numeric)
          [B.9.1] wt.loss = weight loss in last six months

Code Chunk | Output
##################################
# Loading R libraries
##################################
library(moments)
library(car)
library(multcomp)
library(effects)
library(psych)
library(ggplot2)
library(dplyr)
library(ggpubr)
library(rstatix)
library(ggfortify)
library(trend)
library(survival)
library(rms)
library(survminer)
library(Hmisc)
library(finalfit)
library(knitr)
library(gtsummary)

##################################
# Loading the complete dataset
##################################
data(cancer)

##################################
# Reading and creating the complete dataset
##################################
DBP.Complete <- cancer

##################################
# Performing a general exploration of the dataset
##################################
dim(DBP.Complete)
## [1] 228  10
str(DBP.Complete)
## 'data.frame':    228 obs. of  10 variables:
##  $ inst     : num  3 3 3 5 1 12 7 11 1 7 ...
##  $ time     : num  306 455 1010 210 883 ...
##  $ status   : num  2 2 1 2 2 1 2 2 2 2 ...
##  $ age      : num  74 68 56 57 60 74 68 71 53 61 ...
##  $ sex      : num  1 1 1 1 1 1 2 2 1 1 ...
##  $ ph.ecog  : num  1 0 0 1 0 1 2 2 1 2 ...
##  $ ph.karno : num  90 90 90 90 100 50 70 60 70 70 ...
##  $ pat.karno: num  100 90 90 60 90 80 60 80 80 70 ...
##  $ meal.cal : num  1175 1225 NA 1150 NA ...
##  $ wt.loss  : num  NA 15 15 11 0 0 10 1 16 34 ...
summary(DBP.Complete)
##       inst            time            status           age       
##  Min.   : 1.00   Min.   :   5.0   Min.   :1.000   Min.   :39.00  
##  1st Qu.: 3.00   1st Qu.: 166.8   1st Qu.:1.000   1st Qu.:56.00  
##  Median :11.00   Median : 255.5   Median :2.000   Median :63.00  
##  Mean   :11.09   Mean   : 305.2   Mean   :1.724   Mean   :62.45  
##  3rd Qu.:16.00   3rd Qu.: 396.5   3rd Qu.:2.000   3rd Qu.:69.00  
##  Max.   :33.00   Max.   :1022.0   Max.   :2.000   Max.   :82.00  
##  NA's   :1                                                       
##       sex           ph.ecog          ph.karno        pat.karno     
##  Min.   :1.000   Min.   :0.0000   Min.   : 50.00   Min.   : 30.00  
##  1st Qu.:1.000   1st Qu.:0.0000   1st Qu.: 75.00   1st Qu.: 70.00  
##  Median :1.000   Median :1.0000   Median : 80.00   Median : 80.00  
##  Mean   :1.395   Mean   :0.9515   Mean   : 81.94   Mean   : 79.96  
##  3rd Qu.:2.000   3rd Qu.:1.0000   3rd Qu.: 90.00   3rd Qu.: 90.00  
##  Max.   :2.000   Max.   :3.0000   Max.   :100.00   Max.   :100.00  
##                  NA's   :1        NA's   :1        NA's   :3       
##     meal.cal         wt.loss       
##  Min.   :  96.0   Min.   :-24.000  
##  1st Qu.: 635.0   1st Qu.:  0.000  
##  Median : 975.0   Median :  7.000  
##  Mean   : 928.8   Mean   :  9.832  
##  3rd Qu.:1150.0   3rd Qu.: 15.750  
##  Max.   :2600.0   Max.   : 68.000  
##  NA's   :47       NA's   :14
##################################
# Creating standard labels for certain variables
##################################
DBP.Complete$ph.ecog <- factor(DBP.Complete$ph.ecog, 
                     levels = c(3, 2, 1, 0), 
                     labels = c("Bedridden", "Bedridden", "Ambulatory","Asymptomatic"))

DBP.Complete$sex <- factor(DBP.Complete$sex, 
                     levels = c(1, 2), 
                     labels = c("Male", "Female"))

DBP.Complete$statuslevel <- factor(DBP.Complete$status, 
                     levels = c(1, 2), 
                     labels = c(0, 1))

DBP.Complete$status <- ifelse(DBP.Complete$status==2,1,0)

##################################
# Creating an analysis dataset without the subject information column
##################################
DBP.Analysis <- DBP.Complete[,-1]

##################################
# Creating a response-covariate dataset without the treatment column
##################################
DBP.Response.Covariate <- DBP.Analysis[,-5]

##################################
# Formulating a data type assessment summary
##################################
PDA <- DBP.Analysis
(PDA.Summary <- data.frame(
  Column.Index=c(1:length(names(PDA))),
  Column.Name= names(PDA), 
  Column.Type=sapply(PDA, function(x) class(x)), 
  row.names=NULL)
)
##    Column.Index Column.Name Column.Type
## 1             1        time     numeric
## 2             2      status     numeric
## 3             3         age     numeric
## 4             4         sex      factor
## 5             5     ph.ecog      factor
## 6             6    ph.karno     numeric
## 7             7   pat.karno     numeric
## 8             8    meal.cal     numeric
## 9             9     wt.loss     numeric
## 10           10 statuslevel      factor

1.2 Data Quality Assessment


[A] Missing observations noted for 5 variables with NA.Count>0 and Fill.Rate<1.0.
     [A.1] ph.ecog variable (factor)
     [A.2] ph.karno variable (numeric)
     [A.3] pat.karno variable (numeric)
     [A.4] meal.cal variable (numeric)
     [A.5] wt.loss variable (numeric)

[B] No low variance (Unique.Count.Ratio<0.01 or First.Second.Mode.Ratio>5) noted for any response variable.

[C] No high skewness (Skewness>3 or Skewness<(-3)) noted for any response variable.

[D] Row filtering and column filtering were both applied to address quality issues in the data.
     [D.1] 1 patient with missing information for ph.ecog variable removed.
     [D.2] 4 variable columns ph.karno, pat.karno, meal.cal and wt.loss with low fill rates removed.

The pre-processed dataset was composed of the following:

[A] 227 Rows (observations composed of advanced lung cancer patients)

[B] 5 Columns (variables)
     [B.1] 1/5 Factor variable = ph.ecog (factor) referring to the ECOG performance score (0=best, 3=worst) which describes the level of functioning of patients in terms of their ability to care for themselves, daily activity, and physical ability.
          [B.1.1] Asymptomatic = ECOG performance score 0 (asymptomatic)
          [B.1.2] Ambulatory = ECOG performance score 1 (symptomatic but completely ambulatory)
          [B.1.3] Bedridden = ECOG performance score 2 (symptomatic but <50% in bed) or ECOG performance score 3 (symptomatic but >50% in bed)
     [B.2] 1/5 Censoring variable = status (factor)
          [B.2.1] 1 = event, patient died before the end of the study
          [B.2.2] 0 = censored or non-event, patient remains alive until the end of the study, lost to follow-up, experiences a different event that makes further follow-up impossible or withdraws before the end of the study
     [B.3] 1/5 Response variables = time (numeric)
          [B.3.1] time = time in days a patient stays alive up to the point of the patient’s death or being censored
     [B.4] 1/5 Covariate variable = age (numeric)
          [B.4.1] age = patient’s age in years during the conduct of the study
     [B.5] 1/5 Covariate variable = sex (factor)
          [B.5.1] sex = patient’s sex at birth

Code Chunk | Output
##################################
# Loading dataset
##################################
DQA <- DBP.Analysis

##################################
# Listing all predictors
##################################
DQA.Predictors <- DQA[,!names(DQA) %in% c("time","status")]

##################################
# Formulating an overall data quality assessment summary
##################################
(DQA.Summary <- data.frame(
  Column.Index=c(1:length(names(DQA))),
  Column.Name= names(DQA), 
  Column.Type=sapply(DQA, function(x) class(x)), 
  Row.Count=sapply(DQA, function(x) nrow(DQA)),
  NA.Count=sapply(DQA,function(x)sum(is.na(x))),
  Fill.Rate=sapply(DQA,function(x)format(round((sum(!is.na(x))/nrow(DQA)),3),nsmall=3)),
  row.names=NULL)
)
##    Column.Index Column.Name Column.Type Row.Count NA.Count Fill.Rate
## 1             1        time     numeric       228        0     1.000
## 2             2      status     numeric       228        0     1.000
## 3             3         age     numeric       228        0     1.000
## 4             4         sex      factor       228        0     1.000
## 5             5     ph.ecog      factor       228        1     0.996
## 6             6    ph.karno     numeric       228        1     0.996
## 7             7   pat.karno     numeric       228        3     0.987
## 8             8    meal.cal     numeric       228       47     0.794
## 9             9     wt.loss     numeric       228       14     0.939
## 10           10 statuslevel      factor       228        0     1.000
##################################
# Listing all numeric predictors
##################################
DQA.Predictors.Numeric <- as.data.frame(DQA.Predictors[,sapply(DQA.Predictors, is.numeric)])

if (length(names(DQA.Predictors.Numeric))>0) {
    print(paste0("There are ",
               (length(names(DQA.Predictors.Numeric))),
               " numeric predictor variable(s)."))
} else {
  print("There are no numeric predictor variables.")
}
## [1] "There are 5 numeric predictor variable(s)."
##################################
# Listing all factor predictors
##################################
DQA.Predictors.Factor <- as.data.frame(DQA.Predictors[,sapply(DQA.Predictors, is.factor)])

if (length(names(DQA.Predictors.Factor))>0) {
    print(paste0("There are ",
               (length(names(DQA.Predictors.Factor))),
               " factor predictor variable(s)."))
} else {
  print("There are no factor predictor variables.")
}
## [1] "There are 3 factor predictor variable(s)."
##################################
# Checking for missing observations
##################################
if ((nrow(DQA.Summary[DQA.Summary$NA.Count>0,]))>0){
  print(paste0("Missing observations noted for ",
               (nrow(DQA.Summary[DQA.Summary$NA.Count>0,])),
               " variable(s) with NA.Count>0 and Fill.Rate<1.0."))
  DQA.Summary[DQA.Summary$NA.Count>0,]
} else {
  print("No missing observations noted.")
}
## [1] "Missing observations noted for 5 variable(s) with NA.Count>0 and Fill.Rate<1.0."
##   Column.Index Column.Name Column.Type Row.Count NA.Count Fill.Rate
## 5            5     ph.ecog      factor       228        1     0.996
## 6            6    ph.karno     numeric       228        1     0.996
## 7            7   pat.karno     numeric       228        3     0.987
## 8            8    meal.cal     numeric       228       47     0.794
## 9            9     wt.loss     numeric       228       14     0.939
##################################
# Formulating a data quality assessment summary for numeric predictors
##################################

if (length(names(DQA.Predictors.Numeric))>0) {
  
  ##################################
  # Formulating a function to determine the first mode
  ##################################
  FirstModes <- function(x) {
    ux <- unique(na.omit(x))
    tab <- tabulate(match(x, ux))
    ux[tab == max(tab)]
  }

  ##################################
  # Formulating a function to determine the second mode
  ##################################
  SecondModes <- function(x) {
    ux <- unique(na.omit(x))
    tab <- tabulate(match(x, ux))
    fm = ux[tab == max(tab)]
    sm = na.omit(x)[!(na.omit(x) %in% fm)]
    usm <- unique(sm)
    tabsm <- tabulate(match(sm, usm))
    usm[tabsm == max(tabsm)]
  }
  
  (DQA.Predictors.Numeric.Summary <- data.frame(
  Column.Name= names(DQA.Predictors.Numeric), 
  Column.Type=sapply(DQA.Predictors.Numeric, function(x) class(x)), 
  Unique.Count=sapply(DQA.Predictors.Numeric, function(x) length(unique(x))),
  Unique.Count.Ratio=sapply(DQA.Predictors.Numeric, function(x) format(round((length(unique(x))/nrow(DQA.Predictors.Numeric)),3), nsmall=3)),
  First.Mode.Value=sapply(DQA.Predictors.Numeric, function(x) format(round((FirstModes(x)[1]),3),nsmall=3)),
  Second.Mode.Value=sapply(DQA.Predictors.Numeric, function(x) format(round((SecondModes(x)[1]),3),nsmall=3)),
  First.Mode.Count=sapply(DQA.Predictors.Numeric, function(x) sum(na.omit(x) == FirstModes(x)[1])),
  Second.Mode.Count=sapply(DQA.Predictors.Numeric, function(x) sum(na.omit(x) == SecondModes(x)[1])),
  First.Second.Mode.Ratio=sapply(DQA.Predictors.Numeric, function(x) format(round((sum(na.omit(x) == FirstModes(x)[1])/sum(na.omit(x) == SecondModes(x)[1])),3), nsmall=3)),
  Minimum=sapply(DQA.Predictors.Numeric, function(x) format(round(min(x,na.rm = TRUE),3), nsmall=3)),
  Mean=sapply(DQA.Predictors.Numeric, function(x) format(round(mean(x,na.rm = TRUE),3), nsmall=3)),
  Median=sapply(DQA.Predictors.Numeric, function(x) format(round(median(x,na.rm = TRUE),3), nsmall=3)),
  Maximum=sapply(DQA.Predictors.Numeric, function(x) format(round(max(x,na.rm = TRUE),3), nsmall=3)),
  Skewness=sapply(DQA.Predictors.Numeric, function(x) format(round(skewness(x,na.rm = TRUE),3), nsmall=3)),
  Kurtosis=sapply(DQA.Predictors.Numeric, function(x) format(round(kurtosis(x,na.rm = TRUE),3), nsmall=3)),
  Percentile25th=sapply(DQA.Predictors.Numeric, function(x) format(round(quantile(x,probs=0.25,na.rm = TRUE),3), nsmall=3)),
  Percentile75th=sapply(DQA.Predictors.Numeric, function(x) format(round(quantile(x,probs=0.75,na.rm = TRUE),3), nsmall=3)),
  row.names=NULL)
  )  
  
}
##   Column.Name Column.Type Unique.Count Unique.Count.Ratio First.Mode.Value
## 1         age     numeric           42              0.184           60.000
## 2    ph.karno     numeric            7              0.031           90.000
## 3   pat.karno     numeric            9              0.039           90.000
## 4    meal.cal     numeric           61              0.268         1025.000
## 5     wt.loss     numeric           54              0.237            0.000
##   Second.Mode.Value First.Mode.Count Second.Mode.Count First.Second.Mode.Ratio
## 1            74.000               11                10                   1.100
## 2            80.000               74                67                   1.104
## 3            80.000               60                51                   1.176
## 4          1225.000               24                14                   1.714
## 5            10.000               34                13                   2.615
##   Minimum    Mean  Median  Maximum Skewness Kurtosis Percentile25th
## 1  39.000  62.447  63.000   82.000   -0.370    2.626         56.000
## 2  50.000  81.938  80.000  100.000   -0.571    2.827         75.000
## 3  30.000  79.956  80.000  100.000   -0.602    3.157         70.000
## 4  96.000 928.779 975.000 2600.000    1.013    6.423        635.000
## 5 -24.000   9.832   7.000   68.000    1.180    5.379          0.000
##   Percentile75th
## 1         69.000
## 2         90.000
## 3         90.000
## 4       1150.000
## 5         15.750
##################################
# Identifying potential data quality issues for response variables (numeric) 
##################################

##################################
# Checking for zero or near-zero variance predictors
##################################
if (length(names(DQA.Predictors.Numeric))==0) {
  print("No numeric predictors noted.")
} else if (nrow(DQA.Predictors.Numeric.Summary[as.numeric(as.character(DQA.Predictors.Numeric.Summary$First.Second.Mode.Ratio))>5,])>0){
  print(paste0("Low variance observed for ",
               (nrow(DQA.Predictors.Numeric.Summary[as.numeric(as.character(DQA.Predictors.Numeric.Summary$First.Second.Mode.Ratio))>5,])),
               " numeric variable(s) with First.Second.Mode.Ratio>5."))
  DQA.Predictors.Numeric.Summary[as.numeric(as.character(DQA.Predictors.Numeric.Summary$First.Second.Mode.Ratio))>5,]
} else {
  print("No low variance numeric predictors due to high first-second mode ratio noted.")
}
## [1] "No low variance numeric predictors due to high first-second mode ratio noted."
if (length(names(DQA.Predictors.Numeric))==0) {
  print("No numeric predictors noted.")
} else if (nrow(DQA.Predictors.Numeric.Summary[as.numeric(as.character(DQA.Predictors.Numeric.Summary$Unique.Count.Ratio))<0.01,])>0){
  print(paste0("Low variance observed for ",
               (nrow(DQA.Predictors.Numeric.Summary[as.numeric(as.character(DQA.Predictors.Numeric.Summary$Unique.Count.Ratio))<0.01,])),
               " numeric variable(s) with Unique.Count.Ratio<0.01."))
  DQA.Predictors.Numeric.Summary[as.numeric(as.character(DQA.Predictors.Numeric.Summary$Unique.Count.Ratio))<0.01,]
} else {
  print("No low variance numeric predictors due to low unique count ratio noted.")
}
## [1] "No low variance numeric predictors due to low unique count ratio noted."
##################################
# Checking for skewed response variables
##################################
if (length(names(DQA.Predictors.Numeric))==0) {
  print("No response variables noted.")
} else if (nrow(DQA.Predictors.Numeric.Summary[as.numeric(as.character(DQA.Predictors.Numeric.Summary$Skewness))>3 |
                                               as.numeric(as.character(DQA.Predictors.Numeric.Summary$Skewness))<(-3),])>0){
  print(paste0("High skewness observed for ",
  (nrow(DQA.Predictors.Numeric.Summary[as.numeric(as.character(DQA.Predictors.Numeric.Summary$Skewness))>3 |
                                               as.numeric(as.character(DQA.Predictors.Numeric.Summary$Skewness))<(-3),])),
  " response variable(s) with Skewness>3 or Skewness<(-3)."))
  DQA.Predictors.Numeric.Summary[as.numeric(as.character(DQA.Predictors.Numeric.Summary$Skewness))>3 |
                                 as.numeric(as.character(DQA.Predictors.Numeric.Summary$Skewness))<(-3),]
} else {
  print("No skewed response variables noted.")
}
## [1] "No skewed response variables noted."
##################################
# Applying data filtering 
##################################
DBP.ColumnFiltered <- DBP.Analysis[,!names(DBP.Analysis) %in% c("ph.karno","pat.karno","meal.cal","wt.loss")]
DBP.RowFiltered <- DBP.ColumnFiltered[complete.cases(DBP.ColumnFiltered),]
DBP.Analysis.Filtered <- DBP.RowFiltered

##################################
# Loading filtered dataset
##################################
DQA.Filtered <- DBP.Analysis.Filtered

##################################
# Formulating an overall data quality assessment summary
##################################
(DQA.Filtered.Summary <- data.frame(
  Column.Index=c(1:length(names(DQA.Filtered))),
  Column.Name= names(DQA.Filtered), 
  Column.Type=sapply(DQA.Filtered, function(x) class(x)), 
  Row.Count=sapply(DQA.Filtered, function(x) nrow(DQA.Filtered)),
  NA.Count=sapply(DQA.Filtered,function(x)sum(is.na(x))),
  Fill.Rate=sapply(DQA.Filtered,function(x)format(round((sum(!is.na(x))/nrow(DQA.Filtered)),3),nsmall=3)),
  row.names=NULL)
)
##   Column.Index Column.Name Column.Type Row.Count NA.Count Fill.Rate
## 1            1        time     numeric       227        0     1.000
## 2            2      status     numeric       227        0     1.000
## 3            3         age     numeric       227        0     1.000
## 4            4         sex      factor       227        0     1.000
## 5            5     ph.ecog      factor       227        0     1.000
## 6            6 statuslevel      factor       227        0     1.000

1.3 Research Question


Using the cancer dataset, survival analysis and modelling will be conducted to investigate the following :

[A] Research Question : What is the probability that an advanced lung cancer patient under the Asymptomatic, Ambulatory and Bedridden groups will survive (stay alive) after a specified number of days?
     [A.1] Factor variable = ph.ecog
          [A.1.1] Asymptomatic = ECOG performance score 0 (asymptomatic)
          [A.1.2] Ambulatory = ECOG performance score 1 (symptomatic but completely ambulatory)
          [A.1.3] Bedridden = ECOG performance score 2 (symptomatic but <50% in bed) or ECOG performance score 3 (symptomatic but >50% in bed)
     [A.2] Response variable = time (numeric)
     [A.3] Censoring variable = status (factor)
          [A.3.1] 1 = event, patient died before the end of the study
          [A.3.2] 0 = censored or non-event, patient remains alive until until the end of the study, lost to follow-up, experiences a different event that makes further follow-up impossible or withdraws before the end of the study

[B] Research Question : Are there differences in survival between advanced lung cancer patients under the Asymptomatic, Ambulatory and Bedridden groups?
     [B.1] Factor variable = ph.ecog
          [B.1.1] Asymptomatic = ECOG performance score 0 (asymptomatic)
          [B.1.2] Ambulatory = ECOG performance score 1 (symptomatic but completely ambulatory)
          [B.1.3] Bedridden = ECOG performance score 2 (symptomatic but <50% in bed) or ECOG performance score 3 (symptomatic but >50% in bed)
     [B.2] Response variable = time (numeric)
     [B.3] Censoring variable = status (factor)
          [B.3.1] 1 = event, patient died before the end of the study
          [B.3.2] 0 = censored or non-event, patient remains alive until the end of the study, lost to follow-up, experiences a different event that makes further follow-up impossible or withdraws before the end of the study

[C] Research Question : What is the impact of the clinical characteristicS age and sex on the survival of advanced lung cancer patients under the Asymptomatic, Ambulatory and Bedridden groups?
     [C.1] Factor variable = ph.ecog (factor) referring to the ECOG performance score (0=best, 3=worst) which describes the level of functioning of patients in terms of their ability to care for themselves, daily activity, and physical ability.
          [C.1.1] Asymptomatic = ECOG performance score 0 (asymptomatic)
          [C.1.2] Ambulatory = ECOG performance score 1 (symptomatic but completely ambulatory)
          [C.1.3] Bedridden = ECOG performance score 2 (symptomatic but <50% in bed) or ECOG performance score 3 (symptomatic but >50% in bed)
     [C.2] 1/5 Censoring variable = status (factor)
          [C.2.1] 1 = event, patient died before the end of the study
          [C.2.2] 0 = censored or non-event, patient remains alive until the end of the study, lost to follow-up, experiences a different event that makes further follow-up impossible or withdraws before the end of the study
     [C.3] Response variables = time (numeric)
          [C.3.1] time = time in days a patient stays alive up to the point of the patient’s death or being censored
     [C.4] Covariate variable = age (numeric)
          [C.4.1] age = patient’s age in years during the conduct of the study
     [C.5] Covariate variable = sex (factor)
          [C.5.1] sex = patient’s sex at birth

1.4 Data Exploration


Exploratory and comparative analyses of the response variable time by factor variable ph.ecog showed that :

[A] Differences in the proportion of censored and uncensored data (p=0.002, Pearson’s Chi-squared Test) observed between ph.ecog=Asymptomatic (censored=41%, uncensored=59%), ph.ecog=Ambulatory (censored=27%, uncensored=73%) and ph.ecog=Bedridden (censored=12%, uncensored=88%).

[B] With both censored and uncensored data considered, differences in median survival time time (p=0.001, Wilcoxon Rank Sum Test) was observed for ph.ecog=Asymptomatic (303), ph.ecog=Ambulatory (243) and compared to ph.ecog=Bedridden (180). Differences in the age of patients age (p=0.002, Wilcoxon Rank Sum Test) was also noted for ph.ecog=Asymptomatic (61), ph.ecog=Ambulatory (61) and compared to ph.ecog=Bedridden (66).

[C] With only the uncensored considered, decreasing mean survival time time observed ph.ecog=Asymptomatic (331), ph.ecog=Ambulatory (296) and ph.ecog=Bedridden (223). Increasing mean hazard rate was also noted for ph.ecog=Asymptomatic (0.17), ph.ecog=Ambulatory (0.23) and ph.ecog=Bedridden (0.38).

Kaplan-Meier survival curve analysis of the response variable time by factor variable ph.ecog (with censoring variable status considered) showed that :

[A] Differences in the Kaplan-Meier survival curves (p<0.0001, Log Rank Test) were noted between ph.ecog=Asymptomatic (median survival time=394), ph.ecog=Ambulatory (median survival time=306) and ph.ecog=Bedridden (median survival time=103). Post-hoc pairwise log rank test showed that differences in the Kaplan-Meier survival curves were observed between ph.ecog=Ambulatory (median survival time=306) and ph.ecog=Bedridden (median survival time=103) (p<0.0001, Log Rank Test) and ph.ecog=Asymptomatic (median survival time=394), and ph.ecog=Bedridden (median survival time=103) (p=0.0039, Log Rank Test) only. Difference in the Kaplan-Meier survival curves between ph.ecog=Asymptomatic (median survival time=394) and ph.ecog=Ambulatory (median survival time=306) was not statistically significant (p=0.0630, Log Rank Test).

[B] Decreasing survival times were consistently observed for advanced lung cancer patients under ph.ecog=Asymptomatic, ph.ecog=Ambulatory and ph.ecog=Bedridden at various sampled durations including time=183 days (6 months) (Asymptomatic=84%, Ambulatory=72%, Bedridden=50%), time=365 days (12 months) (Asymptomatic=54%, Ambulatory=43%, Bedridden=21%), time=548 days (18 months) (Asymptomatic=37%, Ambulatory=26%, Bedridden=11%), time=730 days (24 months) (Asymptomatic=19%, Ambulatory=11%, Bedridden=4%), and time=913 days (32 months) (Asymptomatic=8%, Ambulatory=6%, Bedridden=0%), except for time=1022 days (last recorded follow-up time) where ph.ecog=Ambulatory showed 6% survival while 0% survival was noted for both ph.ecog=Asymptomatic and ph.ecog=Bedridden groups.

1.4.1 Descriptive Statistics


Code Chunk | Output
##################################
# Reusing the dataset
##################################
head(DBP.Analysis.Filtered)
##   time status age  sex      ph.ecog statuslevel
## 1  306      1  74 Male   Ambulatory           1
## 2  455      1  68 Male Asymptomatic           1
## 3 1010      0  56 Male Asymptomatic           0
## 4  210      1  57 Male   Ambulatory           1
## 5  883      1  60 Male Asymptomatic           1
## 6 1022      0  74 Male   Ambulatory           0
##################################
# Formulating a preliminary summary
# of descriptive statistics
##################################

DBP.Analysis.Filtered %>%
  select(time,statuslevel,ph.ecog,age,sex) %>%
  tbl_summary(
    by = ph.ecog,
    type = all_continuous() ~ "continuous2",
    statistic = all_continuous() ~ c("{N_nonmiss}",
                                     "{mean} ({sd})",
                                     "{median} ({p25}, {p75})",
                                     "{min}, {max}"),
    missing = "no") %>%
  add_overall() %>%
  add_p()
Characteristic Overall
N = 227
1
Bedridden
N = 51
1
Ambulatory
N = 113
1
Asymptomatic
N = 63
1
p-value2
time



0.001
    N Non-missing 227 51 113 63
    Mean (SD) 306 (211) 232 (189) 314 (207) 352 (220)
    Median (Q1, Q3) 259 (167, 404) 180 (95, 310) 243 (177, 426) 303 (224, 442)
    Min, Max 5, 1,022 11, 814 11, 1,022 5, 1,010
statuslevel



0.002
    0 63 (28%) 6 (12%) 31 (27%) 26 (41%)
    1 164 (72%) 45 (88%) 82 (73%) 37 (59%)
age



0.002
    N Non-missing 227 51 113 63
    Mean (SD) 62 (9) 66 (8) 61 (9) 61 (10)
    Median (Q1, Q3) 63 (56, 69) 68 (60, 73) 63 (55, 68) 61 (56, 68)
    Min, Max 39, 82 48, 77 40, 80 39, 82
sex



0.7
    Male 137 (60%) 30 (59%) 71 (63%) 36 (57%)
    Female 90 (40%) 21 (41%) 42 (37%) 27 (43%)
1 n (%)
2 Kruskal-Wallis rank sum test; Pearson’s Chi-squared test
##################################
# Computing for the mean uncensored survival time
# and mean hazard rate between asymptomatic, ambulatory and bedridden groups
##################################
DBP.Analysis.Filtered.DescriptiveStatistics <- DBP.Analysis.Filtered %>%
  group_by(ph.ecog) %>%
  summarise(
    Mean.Uncensored.Survival.Time = mean(time[status==1]),
    Total.Uncensored.Survival.Time = sum(status==1),
    Total.Survival.Time = sum(time),
    Mean.Hazard.Rate = (Total.Uncensored.Survival.Time/Total.Survival.Time)*100)

kable(DBP.Analysis.Filtered.DescriptiveStatistics)
ph.ecog Mean.Uncensored.Survival.Time Total.Uncensored.Survival.Time Total.Survival.Time Mean.Hazard.Rate
Bedridden 223.5556 45 11822 0.3806463
Ambulatory 296.3902 82 35532 0.2307779
Asymptomatic 331.3514 37 22168 0.1669073

1.4.2 Kaplan-Meier Survival Curve


Kaplan-Meier Survival Curve estimates a survival function which makes no assumptions about how the probability that an observation develops the event changes over time. It is a step function plot obtained from the values of a follow-up table which summarizes the experiences of subjects over a pre-defined follow-up period in a study until the time of the event of interest or the end of the study, whichever comes first. The method involves generating a sequential list of time values corresponding to an event or censoring; determining the counts of event-free observations, event and censored cases for each time value; and computing the survival probabilities based on these counts.

Code Chunk | Output
##################################
# Reusing the dataset
##################################
head(DBP.Analysis.Filtered)
##   time status age  sex      ph.ecog statuslevel
## 1  306      1  74 Male   Ambulatory           1
## 2  455      1  68 Male Asymptomatic           1
## 3 1010      0  56 Male Asymptomatic           0
## 4  210      1  57 Male   Ambulatory           1
## 5  883      1  60 Male Asymptomatic           1
## 6 1022      0  74 Male   Ambulatory           0
##################################
# Computing the Kaplan-Meier survival estimates
# using the Baseline data
##################################
DBP.Analysis.Filtered.Baseline.KaplanMeierEstimates <- survfit(Surv(time, status) ~ 1, data = DBP.Analysis.Filtered)
print(DBP.Analysis.Filtered.Baseline.KaplanMeierEstimates)
## Call: survfit(formula = Surv(time, status) ~ 1, data = DBP.Analysis.Filtered)
## 
##        n events median 0.95LCL 0.95UCL
## [1,] 227    164    310     285     363
tbl_survfit(DBP.Analysis.Filtered.Baseline.KaplanMeierEstimates,
            times = c(183,365,548,730,913,1022),
            label_header = "**Day {time}**"
)
Characteristic Day 183 Day 365 Day 548 Day 730 Day 913 Day 1022
Overall 71% (65%, 77%) 41% (35%, 49%) 26% (20%, 33%) 12% (7.2%, 19%) 5.1% (2.1%, 12%) 5.1% (2.1%, 12%)
##################################
# Formulating a summary of the Kaplan-Meier survival estimates
# using the Baseline data
##################################
summary(DBP.Analysis.Filtered.Baseline.KaplanMeierEstimates)
## Call: survfit(formula = Surv(time, status) ~ 1, data = DBP.Analysis.Filtered)
## 
##  time n.risk n.event survival std.err lower 95% CI upper 95% CI
##     5    227       1   0.9956 0.00440       0.9870        1.000
##    11    226       3   0.9824 0.00873       0.9654        1.000
##    12    223       1   0.9780 0.00974       0.9591        0.997
##    13    222       2   0.9692 0.01147       0.9469        0.992
##    15    220       1   0.9648 0.01224       0.9411        0.989
##    26    219       1   0.9604 0.01295       0.9353        0.986
##    30    218       1   0.9559 0.01362       0.9296        0.983
##    31    217       1   0.9515 0.01425       0.9240        0.980
##    53    216       2   0.9427 0.01542       0.9130        0.973
##    54    214       1   0.9383 0.01597       0.9075        0.970
##    59    213       1   0.9339 0.01649       0.9022        0.967
##    60    212       2   0.9251 0.01747       0.8915        0.960
##    61    210       1   0.9207 0.01793       0.8862        0.957
##    62    209       1   0.9163 0.01838       0.8810        0.953
##    65    208       2   0.9075 0.01923       0.8706        0.946
##    79    206       1   0.9031 0.01964       0.8654        0.942
##    81    205       2   0.8943 0.02041       0.8552        0.935
##    88    203       2   0.8855 0.02114       0.8450        0.928
##    92    201       1   0.8811 0.02149       0.8399        0.924
##    93    199       1   0.8766 0.02183       0.8349        0.920
##    95    198       2   0.8678 0.02249       0.8248        0.913
##   105    196       1   0.8633 0.02281       0.8198        0.909
##   107    194       2   0.8544 0.02342       0.8097        0.902
##   110    192       1   0.8500 0.02372       0.8048        0.898
##   116    191       1   0.8455 0.02401       0.7998        0.894
##   118    190       1   0.8411 0.02429       0.7948        0.890
##   122    189       1   0.8366 0.02457       0.7899        0.886
##   131    188       1   0.8322 0.02484       0.7849        0.882
##   132    187       2   0.8233 0.02536       0.7751        0.875
##   135    185       1   0.8188 0.02561       0.7702        0.871
##   142    184       1   0.8144 0.02585       0.7653        0.867
##   144    183       1   0.8099 0.02609       0.7604        0.863
##   145    182       2   0.8010 0.02655       0.7507        0.855
##   147    180       1   0.7966 0.02677       0.7458        0.851
##   153    179       1   0.7921 0.02699       0.7410        0.847
##   156    178       2   0.7832 0.02741       0.7313        0.839
##   163    176       3   0.7699 0.02801       0.7169        0.827
##   166    173       2   0.7610 0.02838       0.7073        0.819
##   167    171       1   0.7565 0.02856       0.7026        0.815
##   170    170       1   0.7521 0.02874       0.6978        0.811
##   175    167       1   0.7476 0.02892       0.6930        0.806
##   176    165       1   0.7431 0.02910       0.6882        0.802
##   177    164       1   0.7385 0.02927       0.6833        0.798
##   179    162       2   0.7294 0.02961       0.6736        0.790
##   180    160       1   0.7248 0.02977       0.6688        0.786
##   181    159       2   0.7157 0.03009       0.6591        0.777
##   182    157       1   0.7112 0.03024       0.6543        0.773
##   183    156       1   0.7066 0.03039       0.6495        0.769
##   186    154       1   0.7020 0.03054       0.6447        0.765
##   189    152       1   0.6974 0.03068       0.6398        0.760
##   194    149       1   0.6927 0.03083       0.6349        0.756
##   197    147       1   0.6880 0.03098       0.6299        0.751
##   199    145       1   0.6833 0.03113       0.6249        0.747
##   201    144       2   0.6738 0.03141       0.6149        0.738
##   202    142       1   0.6690 0.03154       0.6100        0.734
##   207    139       1   0.6642 0.03168       0.6049        0.729
##   208    138       1   0.6594 0.03182       0.5999        0.725
##   210    137       1   0.6546 0.03195       0.5949        0.720
##   212    135       1   0.6497 0.03208       0.5898        0.716
##   218    134       1   0.6449 0.03220       0.5848        0.711
##   222    132       1   0.6400 0.03233       0.5797        0.707
##   223    130       1   0.6351 0.03245       0.5746        0.702
##   226    126       1   0.6300 0.03258       0.5693        0.697
##   229    125       1   0.6250 0.03271       0.5641        0.693
##   230    124       1   0.6200 0.03283       0.5588        0.688
##   239    121       2   0.6097 0.03308       0.5482        0.678
##   245    117       1   0.6045 0.03320       0.5428        0.673
##   246    116       1   0.5993 0.03332       0.5374        0.668
##   267    112       1   0.5939 0.03345       0.5319        0.663
##   268    111       1   0.5886 0.03358       0.5263        0.658
##   269    110       1   0.5832 0.03369       0.5208        0.653
##   270    108       1   0.5778 0.03381       0.5152        0.648
##   283    104       1   0.5723 0.03394       0.5095        0.643
##   284    103       1   0.5667 0.03406       0.5038        0.638
##   285    101       2   0.5555 0.03430       0.4922        0.627
##   286     99       1   0.5499 0.03441       0.4864        0.622
##   288     98       1   0.5443 0.03451       0.4807        0.616
##   291     97       1   0.5387 0.03461       0.4749        0.611
##   293     94       1   0.5329 0.03471       0.4691        0.606
##   301     91       1   0.5271 0.03482       0.4631        0.600
##   303     89       1   0.5212 0.03493       0.4570        0.594
##   305     87       1   0.5152 0.03504       0.4509        0.589
##   306     86       1   0.5092 0.03514       0.4448        0.583
##   310     85       2   0.4972 0.03532       0.4326        0.571
##   320     82       1   0.4911 0.03541       0.4264        0.566
##   329     81       1   0.4851 0.03548       0.4203        0.560
##   337     79       1   0.4789 0.03556       0.4141        0.554
##   340     78       1   0.4728 0.03563       0.4079        0.548
##   345     77       1   0.4667 0.03570       0.4017        0.542
##   348     76       1   0.4605 0.03575       0.3955        0.536
##   350     75       1   0.4544 0.03580       0.3894        0.530
##   351     74       1   0.4482 0.03584       0.3832        0.524
##   353     73       2   0.4360 0.03589       0.3710        0.512
##   361     70       1   0.4297 0.03591       0.3648        0.506
##   363     69       2   0.4173 0.03594       0.3525        0.494
##   364     67       1   0.4110 0.03594       0.3463        0.488
##   371     65       2   0.3984 0.03593       0.3339        0.475
##   387     60       1   0.3918 0.03594       0.3273        0.469
##   390     59       1   0.3851 0.03593       0.3208        0.462
##   394     58       1   0.3785 0.03592       0.3142        0.456
##   426     55       1   0.3716 0.03592       0.3075        0.449
##   428     54       1   0.3647 0.03591       0.3007        0.442
##   429     53       1   0.3578 0.03589       0.2940        0.436
##   433     52       1   0.3510 0.03585       0.2873        0.429
##   442     51       1   0.3441 0.03580       0.2806        0.422
##   444     50       1   0.3372 0.03574       0.2739        0.415
##   450     48       1   0.3302 0.03568       0.2671        0.408
##   455     47       1   0.3231 0.03561       0.2604        0.401
##   457     46       1   0.3161 0.03552       0.2536        0.394
##   460     44       1   0.3089 0.03543       0.2467        0.387
##   473     43       1   0.3017 0.03533       0.2399        0.380
##   477     42       1   0.2946 0.03521       0.2330        0.372
##   519     39       1   0.2870 0.03511       0.2258        0.365
##   520     38       1   0.2795 0.03499       0.2186        0.357
##   524     37       2   0.2643 0.03469       0.2044        0.342
##   533     34       1   0.2566 0.03453       0.1971        0.334
##   550     32       1   0.2486 0.03437       0.1896        0.326
##   558     30       1   0.2403 0.03420       0.1818        0.318
##   567     28       1   0.2317 0.03404       0.1737        0.309
##   574     27       1   0.2231 0.03385       0.1657        0.300
##   583     26       1   0.2145 0.03361       0.1578        0.292
##   613     24       1   0.2056 0.03338       0.1496        0.283
##   624     23       1   0.1967 0.03311       0.1414        0.274
##   641     22       1   0.1877 0.03278       0.1333        0.264
##   643     21       1   0.1788 0.03242       0.1253        0.255
##   654     20       1   0.1698 0.03201       0.1174        0.246
##   655     19       1   0.1609 0.03155       0.1096        0.236
##   687     18       1   0.1520 0.03103       0.1018        0.227
##   689     17       1   0.1430 0.03047       0.0942        0.217
##   705     16       1   0.1341 0.02985       0.0867        0.207
##   707     15       1   0.1251 0.02916       0.0793        0.198
##   728     14       1   0.1162 0.02842       0.0720        0.188
##   731     13       1   0.1073 0.02760       0.0648        0.178
##   735     12       1   0.0983 0.02671       0.0577        0.167
##   765     10       1   0.0885 0.02579       0.0500        0.157
##   791      9       1   0.0787 0.02472       0.0425        0.146
##   814      7       1   0.0674 0.02361       0.0339        0.134
##   883      4       1   0.0506 0.02295       0.0208        0.123
(DBP.Analysis.Filtered.Baseline.KaplanMeierEstimates.Summary <- summary(DBP.Analysis.Filtered.Baseline.KaplanMeierEstimates)$table)
##   records     n.max   n.start    events     rmean se(rmean)    median   0.95LCL 
## 227.00000 227.00000 227.00000 164.00000 377.61957  19.74867 310.00000 285.00000 
##   0.95UCL 
## 363.00000
##################################
# Listing the details of the Kaplan-Meier survival estimates
# using the Baseline data
##################################
(DBP.Analysis.Filtered.Baseline.KaplanMeierEstimates.Details <- surv_summary(DBP.Analysis.Filtered.Baseline.KaplanMeierEstimates))
##     time n.risk n.event n.censor       surv     std.err     upper      lower
## 1      5    227       1        0 0.99559471 0.004415022 1.0000000 0.98701672
## 2     11    226       3        0 0.98237885 0.008889240 0.9996444 0.96541151
## 3     12    223       1        0 0.97797357 0.009960831 0.9972540 0.95906588
## 4     13    222       2        0 0.96916300 0.011839265 0.9919149 0.94693294
## 5     15    220       1        0 0.96475771 0.012685571 0.9890454 0.94106643
## 6     26    219       1        0 0.96035242 0.013485904 0.9860748 0.93530103
## 7     30    218       1        0 0.95594714 0.014248108 0.9830189 0.92962087
## 8     31    217       1        0 0.95154185 0.014978094 0.9798899 0.92401393
## 9     53    216       2        0 0.94273128 0.016358816 0.9734476 0.91298421
## 10    54    214       1        0 0.93832599 0.017016149 0.9701478 0.90754794
## 11    59    213       1        0 0.93392070 0.017654880 0.9668027 0.90215704
## 12    60    212       2        0 0.92511013 0.018884343 0.9599925 0.89149529
## 13    61    210       1        0 0.92070485 0.019478261 0.9565339 0.88621787
## 14    62    209       1        0 0.91629956 0.020060059 0.9530433 0.88097244
## 15    65    208       2        0 0.90748899 0.021191569 0.9459750 0.87056874
## 16    79    206       1        0 0.90308370 0.021743101 0.9424011 0.86540668
## 17    81    205       2        0 0.89427313 0.022821526 0.9351815 0.85515426
## 18    88    203       2        0 0.88546256 0.023871281 0.9278750 0.84498875
## 19    92    201       1        1 0.88105727 0.024386752 0.9241919 0.83993581
## 20    93    199       1        0 0.87662985 0.024901668 0.9204763 0.83487203
## 21    95    198       2        0 0.86777500 0.025915803 0.9129914 0.82479793
## 22   105    196       1        1 0.86334757 0.026415775 0.9092239 0.81978605
## 23   107    194       2        0 0.85444708 0.027413269 0.9016114 0.80975000
## 24   110    192       1        0 0.84999684 0.027906201 0.8977825 0.80475468
## 25   116    191       1        0 0.84554659 0.028395631 0.8939391 0.79977374
## 26   118    190       1        0 0.84109635 0.028881816 0.8900819 0.79480667
## 27   122    189       1        0 0.83664610 0.029364995 0.8862114 0.78985299
## 28   131    188       1        0 0.83219586 0.029845394 0.8823279 0.78491224
## 29   132    187       2        0 0.82329537 0.030798691 0.8745237 0.77506795
## 30   135    185       1        0 0.81884512 0.031271978 0.8706037 0.77016364
## 31   142    184       1        0 0.81439488 0.031743265 0.8666724 0.76527076
## 32   144    183       1        0 0.80994463 0.032212722 0.8627299 0.76038898
## 33   145    182       2        0 0.80104414 0.033146788 0.8548129 0.75065754
## 34   147    180       1        0 0.79659390 0.033611697 0.8508388 0.74580733
## 35   153    179       1        0 0.79214365 0.034075380 0.8468548 0.74096711
## 36   156    178       2        0 0.78324316 0.034999602 0.8388578 0.73131570
## 37   163    176       3        0 0.76989243 0.036379951 0.8267929 0.71690792
## 38   166    173       2        0 0.76099193 0.037297549 0.8187056 0.70734668
## 39   167    171       1        0 0.75654169 0.037755886 0.8146494 0.70257873
## 40   170    170       1        0 0.75209144 0.038214052 0.8105849 0.69781900
## 41   173    169       0        1 0.75209144 0.038214052 0.8105849 0.69781900
## 42   174    168       0        1 0.75209144 0.038214052 0.8105849 0.69781900
## 43   175    167       1        1 0.74758790 0.038683151 0.8064722 0.69300299
## 44   176    165       1        0 0.74305707 0.039157899 0.8023307 0.68816234
## 45   177    164       1        1 0.73852623 0.039632681 0.7981809 0.68333006
## 46   179    162       2        0 0.72940862 0.040594457 0.7898142 0.67362288
## 47   180    160       1        0 0.72484982 0.041075761 0.7856187 0.66878155
## 48   181    159       2        0 0.71573221 0.042039704 0.7772036 0.65912275
## 49   182    157       1        0 0.71117341 0.042522539 0.7729845 0.65430503
## 50   183    156       1        0 0.70661460 0.043006079 0.7687576 0.64949493
## 51   185    155       0        1 0.70661460 0.043006079 0.7687576 0.64949493
## 52   186    154       1        0 0.70202620 0.043496713 0.7645005 0.64465722
## 53   188    153       0        1 0.70202620 0.043496713 0.7645005 0.64465722
## 54   189    152       1        0 0.69740760 0.043994696 0.7602125 0.63979129
## 55   191    151       0        1 0.69740760 0.043994696 0.7602125 0.63979129
## 56   192    150       0        1 0.69740760 0.043994696 0.7602125 0.63979129
## 57   194    149       1        0 0.69272702 0.044507085 0.7558692 0.63485950
## 58   196    148       0        1 0.69272702 0.044507085 0.7558692 0.63485950
## 59   197    147       1        1 0.68801459 0.045027487 0.7514933 0.62989793
## 60   199    145       1        0 0.68326966 0.045556199 0.7470844 0.62490591
## 61   201    144       2        0 0.67377980 0.046617340 0.7382420 0.61494636
## 62   202    142       1        1 0.66903487 0.047149989 0.7338088 0.60997862
## 63   203    140       0        1 0.66903487 0.047149989 0.7338088 0.60997862
## 64   207    139       1        0 0.66422167 0.047699619 0.7293148 0.60493826
## 65   208    138       1        0 0.65940847 0.048250875 0.7248126 0.59990614
## 66   210    137       1        0 0.65459527 0.048803873 0.7203023 0.59488214
## 67   211    136       0        1 0.65459527 0.048803873 0.7203023 0.59488214
## 68   212    135       1        0 0.64974642 0.049366964 0.7157562 0.58982430
## 69   218    134       1        0 0.64489757 0.049932030 0.7112020 0.58477462
## 70   221    133       0        1 0.64489757 0.049932030 0.7112020 0.58477462
## 71   222    132       1        1 0.64001198 0.050507800 0.7066110 0.57968997
## 72   223    130       1        0 0.63508881 0.051094697 0.7019826 0.57456951
## 73   224    129       0        1 0.63508881 0.051094697 0.7019826 0.57456951
## 74   225    128       0        2 0.63508881 0.051094697 0.7019826 0.57456951
## 75   226    126       1        0 0.63004842 0.051712283 0.6972548 0.56931988
## 76   229    125       1        0 0.62500803 0.052332364 0.6925179 0.56407936
## 77   230    124       1        0 0.61996765 0.052955089 0.6877720 0.55884783
## 78   235    123       0        1 0.61996765 0.052955089 0.6877720 0.55884783
## 79   237    122       0        1 0.61996765 0.052955089 0.6877720 0.55884783
## 80   239    121       2        0 0.60972025 0.054250714 0.6781237 0.54821678
## 81   240    119       0        1 0.60972025 0.054250714 0.6781237 0.54821678
## 82   243    118       0        1 0.60972025 0.054250714 0.6781237 0.54821678
## 83   245    117       1        0 0.60450896 0.054925596 0.6732177 0.54281269
## 84   246    116       1        0 0.59929768 0.055603809 0.6683018 0.53741842
## 85   252    115       0        1 0.59929768 0.055603809 0.6683018 0.53741842
## 86   259    114       0        1 0.59929768 0.055603809 0.6683018 0.53741842
## 87   266    113       0        1 0.59929768 0.055603809 0.6683018 0.53741842
## 88   267    112       1        0 0.59394681 0.056322475 0.6632684 0.53187034
## 89   268    111       1        0 0.58859593 0.057044906 0.6582244 0.52633293
## 90   269    110       1        1 0.58324506 0.057771309 0.6531698 0.52080608
## 91   270    108       1        0 0.57784465 0.058515462 0.6480665 0.51523178
## 92   272    107       0        1 0.57784465 0.058515462 0.6480665 0.51523178
## 93   276    106       0        1 0.57784465 0.058515462 0.6480665 0.51523178
## 94   279    105       0        1 0.57784465 0.058515462 0.6480665 0.51523178
## 95   283    104       1        0 0.57228845 0.059307778 0.6428325 0.50948583
## 96   284    103       1        1 0.56673225 0.060104877 0.6375868 0.50375174
## 97   285    101       2        0 0.55550983 0.061746386 0.6269752 0.49219039
## 98   286     99       1        0 0.54989862 0.062575456 0.6216515 0.48642770
## 99   288     98       1        0 0.54428741 0.063410444 0.6163159 0.48067686
## 100  291     97       1        0 0.53867620 0.064251636 0.6109686 0.47493775
## 101  292     96       0        2 0.53867620 0.064251636 0.6109686 0.47493775
## 102  293     94       1        0 0.53294560 0.065135728 0.6055172 0.46907172
## 103  296     93       0        1 0.53294560 0.065135728 0.6055172 0.46907172
## 104  300     92       0        1 0.53294560 0.065135728 0.6055172 0.46907172
## 105  301     91       1        1 0.52708905 0.066066355 0.5999565 0.46307167
## 106  303     89       1        1 0.52116670 0.067025700 0.5943319 0.45700851
## 107  305     87       1        0 0.51517628 0.068015429 0.5886413 0.45088005
## 108  306     86       1        0 0.50918586 0.069013749 0.5829361 0.44476615
## 109  310     85       2        0 0.49720502 0.071037908 0.5714827 0.43258148
## 110  315     83       0        1 0.49720502 0.071037908 0.5714827 0.43258148
## 111  320     82       1        0 0.49114154 0.072089815 0.5656784 0.42642603
## 112  329     81       1        0 0.48507807 0.073152324 0.5598594 0.42028536
## 113  332     80       0        1 0.48507807 0.073152324 0.5598594 0.42028536
## 114  337     79       1        0 0.47893784 0.074253265 0.5539667 0.41407085
## 115  340     78       1        0 0.47279761 0.075366090 0.5480586 0.40787167
## 116  345     77       1        0 0.46665738 0.076491368 0.5421353 0.40168773
## 117  348     76       1        0 0.46051715 0.077629685 0.5361969 0.39551895
## 118  350     75       1        0 0.45437692 0.078781648 0.5302435 0.38936526
## 119  351     74       1        0 0.44823669 0.079947888 0.5242750 0.38322659
## 120  353     73       2        0 0.43595624 0.082325826 0.5122934 0.37099412
## 121  356     71       0        1 0.43595624 0.082325826 0.5122934 0.37099412
## 122  361     70       1        0 0.42972829 0.083573806 0.5062116 0.36480081
## 123  363     69       2        0 0.41727240 0.086123171 0.4940010 0.35246133
## 124  364     67       1        1 0.41104445 0.087426212 0.4878722 0.34631513
## 125  371     65       2        0 0.39839693 0.090176178 0.4754163 0.33385500
## 126  376     63       0        1 0.39839693 0.090176178 0.4754163 0.33385500
## 127  382     62       0        1 0.39839693 0.090176178 0.4754163 0.33385500
## 128  384     61       0        1 0.39839693 0.090176178 0.4754163 0.33385500
## 129  387     60       1        0 0.39175698 0.091729106 0.4689178 0.32729305
## 130  390     59       1        0 0.38511703 0.093308390 0.4623991 0.32075134
## 131  394     58       1        0 0.37847708 0.094915415 0.4558603 0.31422985
## 132  404     57       0        1 0.37847708 0.094915415 0.4558603 0.31422985
## 133  413     56       0        1 0.37847708 0.094915415 0.4558603 0.31422985
## 134  426     55       1        0 0.37159568 0.096672831 0.4491162 0.30745573
## 135  428     54       1        0 0.36471428 0.098463406 0.4423489 0.30070494
## 136  429     53       1        0 0.35783288 0.100289018 0.4355584 0.29397749
## 137  433     52       1        0 0.35095148 0.102151657 0.4287447 0.28727341
## 138  442     51       1        0 0.34407008 0.104053437 0.4219076 0.28059276
## 139  444     50       1        1 0.33718867 0.105996609 0.4150472 0.27393562
## 140  450     48       1        0 0.33016391 0.108067310 0.4080531 0.26714222
## 141  455     47       1        0 0.32313915 0.110186561 0.4010334 0.26037459
## 142  457     46       1        0 0.31611438 0.112357332 0.3939880 0.25363286
## 143  458     45       0        1 0.31611438 0.112357332 0.3939880 0.25363286
## 144  460     44       1        0 0.30892996 0.114685270 0.3867945 0.24674011
## 145  473     43       1        0 0.30174555 0.117074425 0.3795726 0.23987608
## 146  477     42       1        0 0.29456113 0.119528830 0.3723219 0.23304099
## 147  511     41       0        2 0.29456113 0.119528830 0.3723219 0.23304099
## 148  519     39       1        0 0.28700828 0.122318866 0.3647644 0.22582729
## 149  520     38       1        0 0.27945543 0.125192422 0.3571713 0.21864954
## 150  524     37       2        0 0.26434973 0.131215640 0.3418770 0.20440331
## 151  529     35       0        1 0.26434973 0.131215640 0.3418770 0.20440331
## 152  533     34       1        0 0.25657474 0.134568977 0.3340098 0.19709181
## 153  543     33       0        1 0.25657474 0.134568977 0.3340098 0.19709181
## 154  550     32       1        0 0.24855678 0.138263785 0.3259237 0.18955501
## 155  551     31       0        1 0.24855678 0.138263785 0.3259237 0.18955501
## 156  558     30       1        0 0.24027155 0.142359754 0.3175991 0.18177138
## 157  559     29       0        1 0.24027155 0.142359754 0.3175991 0.18177138
## 158  567     28       1        0 0.23169043 0.146932130 0.3090131 0.17371576
## 159  574     27       1        0 0.22310930 0.151702183 0.3003633 0.16572519
## 160  583     26       1        0 0.21452817 0.156690822 0.2916485 0.15780068
## 161  588     25       0        1 0.21452817 0.156690822 0.2916485 0.15780068
## 162  613     24       1        0 0.20558950 0.162368741 0.2826243 0.14955206
## 163  624     23       1        0 0.19665082 0.168344565 0.2735212 0.14138411
## 164  641     22       1        0 0.18771215 0.174655074 0.2643377 0.13329864
## 165  643     21       1        0 0.17877348 0.181343175 0.2550719 0.12529781
## 166  654     20       1        0 0.16983480 0.188459348 0.2457217 0.11738424
## 167  655     19       1        0 0.16089613 0.196063517 0.2362845 0.10956101
## 168  687     18       1        0 0.15195745 0.204227512 0.2267570 0.10183176
## 169  689     17       1        0 0.14301878 0.213038370 0.2171359 0.09420078
## 170  705     16       1        0 0.13408011 0.222602816 0.2074169 0.08667313
## 171  707     15       1        0 0.12514143 0.233053467 0.1975953 0.07925481
## 172  728     14       1        0 0.11620276 0.244557609 0.1876654 0.07195295
## 173  731     13       1        0 0.10726409 0.257329906 0.1776209 0.06477609
## 174  735     12       1        0 0.09832541 0.271651317 0.1674541 0.05773455
## 175  740     11       0        1 0.09832541 0.271651317 0.1674541 0.05773455
## 176  765     10       1        0 0.08849287 0.291385568 0.1566521 0.04998969
## 177  791      9       1        0 0.07866033 0.314315825 0.1456471 0.04248246
## 178  806      8       0        1 0.07866033 0.314315825 0.1456471 0.04248246
## 179  814      7       1        0 0.06742314 0.350148485 0.1339232 0.03394392
## 180  821      6       0        1 0.06742314 0.350148485 0.1339232 0.03394392
## 181  840      5       0        1 0.06742314 0.350148485 0.1339232 0.03394392
## 182  883      4       1        0 0.05056735 0.453803146 0.1230689 0.02077745
## 183  965      3       0        1 0.05056735 0.453803146 0.1230689 0.02077745
## 184 1010      2       0        1 0.05056735 0.453803146 0.1230689 0.02077745
## 185 1022      1       0        1 0.05056735 0.453803146 0.1230689 0.02077745
##################################
# Plotting the Kaplan-Meier survival curves
# using the Baseline data
##################################
SurvivalTimeInWeek.KaplanMeier.Baseline <- ggsurvplot(DBP.Analysis.Filtered.Baseline.KaplanMeierEstimates,
                                                     title = "Kaplan-Meier Survival Curve (Baseline)",
                                                     pval = FALSE,
                                                     conf.int = TRUE,
                                                     conf.int.style = "ribbon",
                                                     xlab = "Time (Days)",
                                                     ylab="Estimated Survival Probability",
                                                     break.time.by = 100,
                                                     ggtheme = theme_bw(),
                                                     risk.table = "abs_pct",
                                                     risk.table.title="Number at Risk (Survival Probability)",
                                                     risk.table.y.text.col = FALSE,
                                                     risk.table.y.text = TRUE,
                                                     fontsize = 3,
                                                     ncensor.plot = FALSE,
                                                     surv.median.line = "hv",
                                                     palette = c("#000000"))

ggpar(SurvivalTimeInWeek.KaplanMeier.Baseline,
      font.title = c(14,"bold"),
      font.x = c(12,"bold"),
      font.y = c(12,"bold"),
      font.legend=c(12),
      font.xtickslab=c(9,"black"),
      font.ytickslab=c(9,"black"))

##################################
# Computing the Kaplan-Meier survival estimates
# using the Factor Variable
##################################
DBP.Analysis.Filtered.KaplanMeierEstimates <- survfit(Surv(time, status) ~ ph.ecog, data = DBP.Analysis.Filtered)
print(DBP.Analysis.Filtered.KaplanMeierEstimates)
## Call: survfit(formula = Surv(time, status) ~ ph.ecog, data = DBP.Analysis.Filtered)
## 
##                        n events median 0.95LCL 0.95UCL
## ph.ecog=Bedridden     51     45    183     153     288
## ph.ecog=Ambulatory   113     82    306     268     429
## ph.ecog=Asymptomatic  63     37    394     348     574
tbl_survfit(DBP.Analysis.Filtered.KaplanMeierEstimates,
            times = c(183,365,548,730,913,1022),
            label_header = "**Day {time}**"
)
Characteristic Day 183 Day 365 Day 548 Day 730 Day 913 Day 1022
ph.ecog





    Bedridden 50% (37%, 66%) 21% (12%, 37%) 11% (4.6%, 26%) 3.6% (0.6%, 22%) — (—, —) — (—, —)
    Ambulatory 72% (65%, 81%) 43% (34%, 54%) 26% (18%, 38%) 11% (5.8%, 22%) 6.1% (2.3%, 16%) 6.1% (2.3%, 16%)
    Asymptomatic 84% (76%, 94%) 54% (41%, 70%) 37% (25%, 55%) 19% (9.4%, 40%) 7.7% (1.5%, 39%) — (—, —)
##################################
# Formulating a summary of the Kaplan-Meier survival estimates
# using the Factor Variable
##################################
summary(DBP.Analysis.Filtered.KaplanMeierEstimates)
## Call: survfit(formula = Surv(time, status) ~ ph.ecog, data = DBP.Analysis.Filtered)
## 
##                 ph.ecog=Bedridden 
##  time n.risk n.event survival std.err lower 95% CI upper 95% CI
##    11     51       1   0.9804  0.0194      0.94307        1.000
##    12     50       1   0.9608  0.0272      0.90896        1.000
##    13     49       1   0.9412  0.0329      0.87877        1.000
##    26     48       1   0.9216  0.0376      0.85066        0.998
##    30     47       1   0.9020  0.0416      0.82393        0.987
##    53     46       1   0.8824  0.0451      0.79821        0.975
##    54     45       1   0.8627  0.0482      0.77329        0.963
##    61     44       1   0.8431  0.0509      0.74901        0.949
##    65     43       1   0.8235  0.0534      0.72528        0.935
##    81     42       1   0.8039  0.0556      0.70202        0.921
##    93     40       1   0.7838  0.0577      0.67847        0.906
##    95     39       1   0.7637  0.0596      0.65534        0.890
##   105     38       1   0.7436  0.0614      0.63258        0.874
##   107     36       1   0.7230  0.0630      0.60940        0.858
##   118     35       1   0.7023  0.0645      0.58657        0.841
##   122     34       1   0.6817  0.0659      0.56406        0.824
##   132     33       1   0.6610  0.0670      0.54187        0.806
##   145     32       1   0.6403  0.0680      0.51996        0.789
##   153     31       1   0.6197  0.0689      0.49834        0.771
##   156     30       1   0.5990  0.0696      0.47698        0.752
##   163     29       1   0.5784  0.0702      0.45588        0.734
##   166     28       1   0.5577  0.0707      0.43503        0.715
##   177     27       1   0.5371  0.0710      0.41442        0.696
##   180     26       1   0.5164  0.0712      0.39406        0.677
##   183     25       1   0.4958  0.0713      0.37394        0.657
##   199     24       1   0.4751  0.0713      0.35406        0.638
##   201     23       1   0.4544  0.0711      0.33441        0.618
##   208     22       1   0.4338  0.0708      0.31500        0.597
##   212     20       1   0.4121  0.0705      0.29467        0.576
##   222     19       1   0.3904  0.0701      0.27464        0.555
##   239     18       1   0.3687  0.0694      0.25490        0.533
##   285     17       1   0.3470  0.0687      0.23547        0.511
##   288     16       1   0.3253  0.0677      0.21636        0.489
##   291     15       1   0.3036  0.0666      0.19757        0.467
##   310     13       1   0.2803  0.0654      0.17738        0.443
##   329     12       1   0.2569  0.0640      0.15767        0.419
##   351     11       1   0.2336  0.0623      0.13847        0.394
##   361     10       1   0.2102  0.0603      0.11982        0.369
##   387      9       1   0.1869  0.0579      0.10176        0.343
##   444      8       1   0.1635  0.0552      0.08435        0.317
##   524      6       1   0.1363  0.0523      0.06421        0.289
##   533      5       1   0.1090  0.0484      0.04564        0.260
##   654      3       1   0.0727  0.0438      0.02227        0.237
##   707      2       1   0.0363  0.0338      0.00588        0.225
##   814      1       1   0.0000     NaN           NA           NA
## 
##                 ph.ecog=Ambulatory 
##  time n.risk n.event survival std.err lower 95% CI upper 95% CI
##    11    113       1   0.9912 0.00881       0.9740        1.000
##    13    112       1   0.9823 0.01240       0.9583        1.000
##    59    111       1   0.9735 0.01512       0.9443        1.000
##    60    110       2   0.9558 0.01935       0.9186        0.994
##    62    108       1   0.9469 0.02109       0.9064        0.989
##    79    107       1   0.9381 0.02268       0.8946        0.984
##    88    106       2   0.9204 0.02547       0.8718        0.972
##    92    104       1   0.9115 0.02672       0.8606        0.965
##    95    103       1   0.9027 0.02789       0.8496        0.959
##   107    102       1   0.8938 0.02898       0.8388        0.952
##   110    101       1   0.8850 0.03002       0.8280        0.946
##   116    100       1   0.8761 0.03099       0.8174        0.939
##   131     99       1   0.8673 0.03192       0.8069        0.932
##   132     98       1   0.8584 0.03280       0.7965        0.925
##   135     97       1   0.8496 0.03363       0.7861        0.918
##   142     96       1   0.8407 0.03443       0.7759        0.911
##   144     95       1   0.8319 0.03518       0.7657        0.904
##   145     94       1   0.8230 0.03590       0.7556        0.896
##   156     93       1   0.8142 0.03659       0.7455        0.889
##   163     92       2   0.7965 0.03788       0.7256        0.874
##   167     90       1   0.7876 0.03848       0.7157        0.867
##   170     89       1   0.7788 0.03905       0.7059        0.859
##   175     86       1   0.7697 0.03963       0.6958        0.851
##   179     84       2   0.7514 0.04075       0.6756        0.836
##   181     82       2   0.7331 0.04177       0.6556        0.820
##   182     80       1   0.7239 0.04224       0.6457        0.812
##   186     78       1   0.7146 0.04270       0.6356        0.803
##   194     75       1   0.7051 0.04318       0.6253        0.795
##   197     73       1   0.6954 0.04366       0.6149        0.786
##   202     71       1   0.6856 0.04413       0.6044        0.778
##   207     69       1   0.6757 0.04459       0.5937        0.769
##   210     68       1   0.6658 0.04503       0.5831        0.760
##   218     67       1   0.6558 0.04544       0.5725        0.751
##   223     64       1   0.6456 0.04587       0.5616        0.742
##   226     62       1   0.6352 0.04630       0.5506        0.733
##   229     61       1   0.6247 0.04670       0.5396        0.723
##   230     60       1   0.6143 0.04707       0.5287        0.714
##   239     58       1   0.6037 0.04743       0.5176        0.704
##   245     56       1   0.5930 0.04779       0.5063        0.694
##   268     55       1   0.5822 0.04812       0.4951        0.685
##   269     54       1   0.5714 0.04843       0.4839        0.675
##   270     53       1   0.5606 0.04870       0.4729        0.665
##   283     50       1   0.5494 0.04900       0.4613        0.654
##   284     49       1   0.5382 0.04926       0.4498        0.644
##   293     48       1   0.5270 0.04950       0.4384        0.633
##   301     46       1   0.5155 0.04973       0.4267        0.623
##   305     43       1   0.5035 0.05000       0.4145        0.612
##   306     42       1   0.4915 0.05022       0.4023        0.601
##   310     41       1   0.4796 0.05041       0.3903        0.589
##   345     40       1   0.4676 0.05055       0.3783        0.578
##   363     38       2   0.4430 0.05080       0.3538        0.555
##   364     36       1   0.4307 0.05086       0.3417        0.543
##   371     34       1   0.4180 0.05091       0.3292        0.531
##   390     32       1   0.4049 0.05097       0.3164        0.518
##   426     29       1   0.3910 0.05109       0.3026        0.505
##   429     28       1   0.3770 0.05114       0.2890        0.492
##   450     27       1   0.3630 0.05112       0.2755        0.478
##   457     26       1   0.3491 0.05102       0.2621        0.465
##   460     24       1   0.3345 0.05093       0.2482        0.451
##   473     23       1   0.3200 0.05075       0.2345        0.437
##   477     22       1   0.3054 0.05048       0.2209        0.422
##   519     20       1   0.2902 0.05021       0.2067        0.407
##   520     19       1   0.2749 0.04984       0.1927        0.392
##   524     18       1   0.2596 0.04935       0.1789        0.377
##   550     16       1   0.2434 0.04886       0.1642        0.361
##   567     15       1   0.2272 0.04823       0.1498        0.344
##   583     14       1   0.2109 0.04743       0.1358        0.328
##   613     13       1   0.1947 0.04648       0.1220        0.311
##   624     12       1   0.1785 0.04535       0.1085        0.294
##   641     11       1   0.1623 0.04403       0.0953        0.276
##   687     10       1   0.1460 0.04251       0.0825        0.258
##   689      9       1   0.1298 0.04077       0.0701        0.240
##   728      8       1   0.1136 0.03877       0.0582        0.222
##   731      7       1   0.0974 0.03647       0.0467        0.203
##   735      6       1   0.0811 0.03381       0.0359        0.184
##   765      4       1   0.0608 0.03085       0.0225        0.164
## 
##                 ph.ecog=Asymptomatic 
##  time n.risk n.event survival std.err lower 95% CI upper 95% CI
##     5     63       1   0.9841  0.0157       0.9537        1.000
##    11     62       1   0.9683  0.0221       0.9259        1.000
##    15     61       1   0.9524  0.0268       0.9012        1.000
##    31     60       1   0.9365  0.0307       0.8782        0.999
##    53     59       1   0.9206  0.0341       0.8562        0.990
##    65     58       1   0.9048  0.0370       0.8351        0.980
##    81     57       1   0.8889  0.0396       0.8146        0.970
##   147     56       1   0.8730  0.0419       0.7946        0.959
##   166     55       1   0.8571  0.0441       0.7749        0.948
##   176     53       1   0.8410  0.0461       0.7553        0.936
##   189     52       1   0.8248  0.0480       0.7359        0.924
##   201     50       1   0.8083  0.0498       0.7164        0.912
##   246     44       1   0.7899  0.0519       0.6944        0.899
##   267     40       1   0.7702  0.0543       0.6709        0.884
##   285     36       1   0.7488  0.0568       0.6453        0.869
##   286     35       1   0.7274  0.0591       0.6203        0.853
##   303     32       1   0.7047  0.0615       0.5940        0.836
##   320     30       1   0.6812  0.0637       0.5670        0.818
##   337     28       1   0.6568  0.0659       0.5395        0.800
##   340     27       1   0.6325  0.0678       0.5126        0.780
##   348     26       1   0.6082  0.0695       0.4862        0.761
##   350     25       1   0.5839  0.0708       0.4603        0.741
##   353     24       2   0.5352  0.0728       0.4100        0.699
##   371     22       1   0.5109  0.0734       0.3855        0.677
##   394     19       1   0.4840  0.0743       0.3582        0.654
##   428     18       1   0.4571  0.0749       0.3315        0.630
##   433     17       1   0.4302  0.0752       0.3055        0.606
##   442     16       1   0.4033  0.0751       0.2800        0.581
##   455     14       1   0.3745  0.0751       0.2528        0.555
##   558     12       1   0.3433  0.0750       0.2237        0.527
##   574     10       1   0.3090  0.0750       0.1920        0.497
##   643      8       1   0.2704  0.0749       0.1571        0.465
##   655      7       1   0.2317  0.0735       0.1245        0.431
##   705      6       1   0.1931  0.0707       0.0943        0.396
##   791      5       1   0.1545  0.0662       0.0667        0.358
##   883      2       1   0.0772  0.0639       0.0153        0.391
(DBP.Analysis.Filtered.KaplanMeierEstimates.Summary <- summary(DBP.Analysis.Filtered.KaplanMeierEstimates)$table)
##                      records n.max n.start events    rmean se(rmean) median
## ph.ecog=Bedridden         51    51      51     45 255.7636  30.74032    183
## ph.ecog=Ambulatory       113   113     113     82 384.8410  27.28943    306
## ph.ecog=Asymptomatic      63    63      63     37 465.3131  42.88835    394
##                      0.95LCL 0.95UCL
## ph.ecog=Bedridden        153     288
## ph.ecog=Ambulatory       268     429
## ph.ecog=Asymptomatic     348     574
##################################
# Listing the details of the Kaplan-Meier survival estimates
# using the Factor Variable
##################################
(DBP.Analysis.Filtered.KaplanMeierEstimates.Details <- surv_summary(DBP.Analysis.Filtered.KaplanMeierEstimates))
##     time n.risk n.event n.censor       surv     std.err     upper       lower
## 1     11     51       1        0 0.98039216 0.019802951 1.0000000 0.943069123
## 2     12     50       1        0 0.96078431 0.028289930 1.0000000 0.908961465
## 3     13     49       1        0 0.94117647 0.035007002 1.0000000 0.878765599
## 4     26     48       1        0 0.92156863 0.040850369 0.9983885 0.850659556
## 5     30     47       1        0 0.90196078 0.046165867 0.9873795 0.823931673
## 6     53     46       1        0 0.88235294 0.051130999 0.9753604 0.798214389
## 7     54     45       1        0 0.86274510 0.055851854 0.9625509 0.773288081
## 8     61     44       1        0 0.84313725 0.060398434 0.9490946 0.749009005
## 9     65     43       1        0 0.82352941 0.064820372 0.9350919 0.725277013
## 10    81     42       1        0 0.80392157 0.069154904 0.9206158 0.702019086
## 11    92     41       0        1 0.80392157 0.069154904 0.9206158 0.702019086
## 12    93     40       1        0 0.78382353 0.073643916 0.9055326 0.678472862
## 13    95     39       1        0 0.76372549 0.078090910 0.8900377 0.655339254
## 14   105     38       1        1 0.74362745 0.082519257 0.8741701 0.632579181
## 15   107     36       1        0 0.72297113 0.087195634 0.8577130 0.609396420
## 16   118     35       1        0 0.70231481 0.091888055 0.8409053 0.586565580
## 17   122     34       1        0 0.68165850 0.096616149 0.8237713 0.564062252
## 18   132     33       1        0 0.66100218 0.101398471 0.8063311 0.541866566
## 19   145     32       1        0 0.64034586 0.106253068 0.7886011 0.519962270
## 20   153     31       1        0 0.61968954 0.111197947 0.7705947 0.498336048
## 21   156     30       1        0 0.59903322 0.116251489 0.7523230 0.476977029
## 22   163     29       1        0 0.57837691 0.121432845 0.7337950 0.455876410
## 23   166     28       1        0 0.55772059 0.126762325 0.7150180 0.435027178
## 24   177     27       1        0 0.53706427 0.132261818 0.6959976 0.414423903
## 25   180     26       1        0 0.51640795 0.137955246 0.6767381 0.394062586
## 26   183     25       1        0 0.49575163 0.143869096 0.6572427 0.373940546
## 27   199     24       1        0 0.47509532 0.150033033 0.6375131 0.354056360
## 28   201     23       1        0 0.45443900 0.156480655 0.6175501 0.334409817
## 29   208     22       1        0 0.43378268 0.163250414 0.5973532 0.315001922
## 30   211     21       0        1 0.43378268 0.163250414 0.5973532 0.315001922
## 31   212     20       1        0 0.41209355 0.171120649 0.5763071 0.294671173
## 32   222     19       1        0 0.39040441 0.179461007 0.5549734 0.274635852
## 33   239     18       1        0 0.36871528 0.188346030 0.5333491 0.254900508
## 34   285     17       1        0 0.34702614 0.197865352 0.5114292 0.235471799
## 35   288     16       1        0 0.32533701 0.208128240 0.4892069 0.216358714
## 36   291     15       1        0 0.30364788 0.219269854 0.4666734 0.197572916
## 37   292     14       0        1 0.30364788 0.219269854 0.4666734 0.197572916
## 38   310     13       1        0 0.28029035 0.233429916 0.4428983 0.177383098
## 39   329     12       1        0 0.25693282 0.249129049 0.4186765 0.157674168
## 40   351     11       1        0 0.23357529 0.266751180 0.3939906 0.138473886
## 41   361     10       1        0 0.21021776 0.286822773 0.3688191 0.119818925
## 42   387      9       1        0 0.18686023 0.310090619 0.3431362 0.101757697
## 43   444      8       1        0 0.16350270 0.337658607 0.3169133 0.084354724
## 44   511      7       0        1 0.16350270 0.337658607 0.3169133 0.084354724
## 45   524      6       1        0 0.13625225 0.383857615 0.2891238 0.064210122
## 46   533      5       1        0 0.10900180 0.444237176 0.2603569 0.045635026
## 47   551      4       0        1 0.10900180 0.444237176 0.2603569 0.045635026
## 48   654      3       1        0 0.07266787 0.603335176 0.2370840 0.022273198
## 49   707      2       1        0 0.03633393 0.929523176 0.2246591 0.005876258
## 50   814      1       1        0 0.00000000         Inf        NA          NA
## 51    11    113       1        0 0.99115044 0.008888977 1.0000000 0.974032097
## 52    13    112       1        0 0.98230088 0.012627410 1.0000000 0.958288032
## 53    59    111       1        0 0.97345133 0.015535494 1.0000000 0.944257418
## 54    60    110       2        0 0.95575221 0.020241090 0.9944308 0.918578053
## 55    62    108       1        0 0.94690265 0.022276375 0.9891611 0.906449575
## 56    79    107       1        0 0.93805310 0.024174465 0.9835688 0.894643643
## 57    88    106       2        0 0.92035398 0.027673581 0.9716519 0.871764342
## 58    92    104       1        0 0.91150442 0.029311778 0.9654038 0.860614285
## 59    95    103       1        0 0.90265487 0.030892783 0.9589980 0.849621989
## 60   107    102       1        0 0.89380531 0.032425801 0.9524536 0.838768358
## 61   110    101       1        0 0.88495575 0.033918173 0.9457857 0.828038167
## 62   116    100       1        0 0.87610619 0.035375876 0.9390068 0.817419043
## 63   131     99       1        0 0.86725664 0.036803860 0.9321271 0.806900770
## 64   132     98       1        0 0.85840708 0.038206293 0.9251551 0.796474792
## 65   135     97       1        0 0.84955752 0.039586729 0.9180981 0.786133864
## 66   142     96       1        0 0.84070796 0.040948239 0.9109622 0.775871783
## 67   144     95       1        0 0.83185841 0.042293502 0.9037529 0.765683195
## 68   145     94       1        0 0.82300885 0.043624886 0.8964748 0.755563440
## 69   156     93       1        0 0.81415929 0.044944496 0.8891319 0.745508432
## 70   163     92       2        0 0.79646018 0.047555794 0.8742661 0.725578658
## 71   167     90       1        0 0.78761062 0.048850768 0.8667491 0.715697852
## 72   170     89       1        0 0.77876106 0.050140591 0.8591796 0.705869603
## 73   173     88       0        1 0.77876106 0.050140591 0.8591796 0.705869603
## 74   174     87       0        1 0.77876106 0.050140591 0.8591796 0.705869603
## 75   175     86       1        0 0.76970570 0.051486675 0.8514325 0.695823618
## 76   177     85       0        1 0.76970570 0.051486675 0.8514325 0.695823618
## 77   179     84       2        0 0.75137937 0.054233180 0.8356466 0.675609742
## 78   181     82       2        0 0.73305305 0.056974695 0.8196574 0.655599262
## 79   182     80       1        0 0.72388989 0.058346754 0.8115912 0.645665619
## 80   185     79       0        1 0.72388989 0.058346754 0.8115912 0.645665619
## 81   186     78       1        0 0.71460925 0.059756538 0.8034031 0.635629103
## 82   188     77       0        1 0.71460925 0.059756538 0.8034031 0.635629103
## 83   192     76       0        1 0.71460925 0.059756538 0.8034031 0.635629103
## 84   194     75       1        0 0.70508112 0.061245604 0.7950079 0.625326357
## 85   196     74       0        1 0.70508112 0.061245604 0.7950079 0.625326357
## 86   197     73       1        1 0.69542248 0.062779637 0.7864785 0.614908646
## 87   202     71       1        0 0.68562779 0.064362179 0.7778101 0.604370460
## 88   203     70       0        1 0.68562779 0.064362179 0.7778101 0.604370460
## 89   207     69       1        0 0.67569116 0.065997112 0.7689978 0.593705939
## 90   210     68       1        0 0.66575452 0.067639556 0.7601320 0.583094886
## 91   218     67       1        0 0.65581789 0.069291064 0.7512144 0.572535736
## 92   221     66       0        1 0.65581789 0.069291064 0.7512144 0.572535736
## 93   222     65       0        1 0.65581789 0.069291064 0.7512144 0.572535736
## 94   223     64       1        0 0.64557074 0.071058198 0.7420423 0.561641238
## 95   225     63       0        1 0.64557074 0.071058198 0.7420423 0.561641238
## 96   226     62       1        0 0.63515830 0.072894978 0.7327069 0.550596775
## 97   229     61       1        0 0.62474587 0.074745581 0.7233141 0.539609817
## 98   230     60       1        0 0.61433344 0.076611929 0.7138654 0.528678884
## 99   237     59       0        1 0.61433344 0.076611929 0.7138654 0.528678884
## 100  239     58       1        0 0.60374149 0.078561238 0.7042429 0.517582486
## 101  243     57       0        1 0.60374149 0.078561238 0.7042429 0.517582486
## 102  245     56       1        0 0.59296039 0.080601138 0.6944380 0.506311590
## 103  268     55       1        0 0.58217929 0.082663436 0.6845734 0.495100663
## 104  269     54       1        0 0.57139819 0.084750515 0.6746502 0.483948439
## 105  270     53       1        0 0.56061709 0.086864805 0.6646696 0.472853796
## 106  272     52       0        1 0.56061709 0.086864805 0.6646696 0.472853796
## 107  279     51       0        1 0.56061709 0.086864805 0.6646696 0.472853796
## 108  283     50       1        0 0.54940475 0.089183281 0.6543428 0.461295762
## 109  284     49       1        0 0.53819241 0.091535937 0.6439514 0.449802679
## 110  293     48       1        0 0.52698007 0.093925982 0.6334964 0.438373455
## 111  296     47       0        1 0.52698007 0.093925982 0.6334964 0.438373455
## 112  301     46       1        1 0.51552398 0.096463371 0.6228144 0.426716171
## 113  303     44       0        1 0.51552398 0.096463371 0.6228144 0.426716171
## 114  305     43       1        0 0.50353505 0.099291952 0.6117122 0.414488269
## 115  306     42       1        0 0.49154612 0.102174419 0.6005308 0.402340035
## 116  310     41       1        0 0.47955719 0.105115974 0.5892713 0.390270323
## 117  345     40       1        0 0.46756826 0.108122124 0.5779347 0.378278192
## 118  356     39       0        1 0.46756826 0.108122124 0.5779347 0.378278192
## 119  363     38       2        0 0.44295941 0.114683835 0.5546040 0.353789443
## 120  364     36       1        1 0.43065498 0.118093322 0.5428136 0.341671105
## 121  371     34       1        0 0.41798865 0.121808449 0.5306987 0.329216015
## 122  376     33       0        1 0.41798865 0.121808449 0.5306987 0.329216015
## 123  390     32       1        0 0.40492651 0.125878365 0.5182318 0.316394081
## 124  404     31       0        1 0.40492651 0.125878365 0.5182318 0.316394081
## 125  413     30       0        1 0.40492651 0.125878365 0.5182318 0.316394081
## 126  426     29       1        0 0.39096353 0.130678575 0.5050915 0.302623352
## 127  429     28       1        0 0.37700054 0.135645277 0.4918169 0.288988464
## 128  450     27       1        0 0.36303756 0.140798234 0.4784089 0.275488761
## 129  457     26       1        0 0.34907458 0.146159516 0.4648678 0.262124137
## 130  458     25       0        1 0.34907458 0.146159516 0.4648678 0.262124137
## 131  460     24       1        0 0.33452980 0.152230741 0.4508311 0.248230860
## 132  473     23       1        0 0.31998503 0.158589038 0.4366374 0.234497612
## 133  477     22       1        0 0.30544025 0.165272457 0.4222858 0.220925630
## 134  511     21       0        1 0.30544025 0.165272457 0.4222858 0.220925630
## 135  519     20       1        0 0.29016824 0.173050756 0.4073343 0.206703965
## 136  520     19       1        0 0.27489623 0.181302346 0.3921874 0.192683242
## 137  524     18       1        0 0.25962422 0.190101327 0.3768424 0.178867178
## 138  529     17       0        1 0.25962422 0.190101327 0.3768424 0.178867178
## 139  550     16       1        0 0.24339770 0.200761503 0.3607489 0.164220728
## 140  567     15       1        0 0.22717119 0.212290099 0.3443935 0.149848221
## 141  583     14       1        0 0.21094468 0.224859048 0.3277698 0.135758865
## 142  613     13       1        0 0.19471816 0.238687762 0.3108693 0.121964958
## 143  624     12       1        0 0.17849165 0.254062208 0.2936811 0.108482518
## 144  641     11       1        0 0.16226514 0.271364173 0.2761918 0.095332199
## 145  687     10       1        0 0.14603862 0.291117890 0.2583853 0.082540620
## 146  689      9       1        0 0.12981211 0.314067691 0.2402426 0.070142348
## 147  728      8       1        0 0.11358559 0.341314602 0.2217434 0.058182950
## 148  731      7       1        0 0.09735908 0.374573332 0.2028681 0.046723898
## 149  735      6       1        0 0.08113257 0.416699550 0.1836075 0.035850888
## 150  740      5       0        1 0.08113257 0.416699550 0.1836075 0.035850888
## 151  765      4       1        0 0.06084943 0.506923907 0.1643429 0.022530046
## 152  806      3       0        1 0.06084943 0.506923907 0.1643429 0.022530046
## 153  965      2       0        1 0.06084943 0.506923907 0.1643429 0.022530046
## 154 1022      1       0        1 0.06084943 0.506923907 0.1643429 0.022530046
## 155    5     63       1        0 0.98412698 0.016000512 1.0000000 0.953743255
## 156   11     62       1        0 0.96825397 0.022812864 1.0000000 0.925914618
## 157   15     61       1        0 0.95238095 0.028171808 1.0000000 0.901219985
## 158   31     60       1        0 0.93650794 0.032804522 0.9986992 0.878189424
## 159   53     59       1        0 0.92063492 0.036991397 0.9898618 0.856249459
## 160   65     58       1        0 0.90476190 0.040875956 0.9802300 0.835104126
## 161   81     57       1        0 0.88888889 0.044543540 0.9699805 0.814576632
## 162  147     56       1        0 0.87301587 0.048049998 0.9592292 0.794551236
## 163  166     55       1        0 0.85714286 0.051434450 0.9480567 0.774947224
## 164  175     54       0        1 0.85714286 0.051434450 0.9480567 0.774947224
## 165  176     53       1        0 0.84097035 0.054848403 0.9364136 0.755255052
## 166  189     52       1        0 0.82479784 0.058184373 0.9244302 0.735903535
## 167  191     51       0        1 0.82479784 0.058184373 0.9244302 0.735903535
## 168  201     50       1        0 0.80830189 0.061592082 0.9120127 0.716384726
## 169  202     49       0        1 0.80830189 0.061592082 0.9120127 0.716384726
## 170  224     48       0        1 0.80830189 0.061592082 0.9120127 0.716384726
## 171  225     47       0        1 0.80830189 0.061592082 0.9120127 0.716384726
## 172  235     46       0        1 0.80830189 0.061592082 0.9120127 0.716384726
## 173  240     45       0        1 0.80830189 0.061592082 0.9120127 0.716384726
## 174  246     44       1        0 0.78993139 0.065742876 0.8985656 0.694430735
## 175  252     43       0        1 0.78993139 0.065742876 0.8985656 0.694430735
## 176  259     42       0        1 0.78993139 0.065742876 0.8985656 0.694430735
## 177  266     41       0        1 0.78993139 0.065742876 0.8985656 0.694430735
## 178  267     40       1        0 0.77018310 0.070449637 0.8842210 0.670852662
## 179  269     39       0        1 0.77018310 0.070449637 0.8842210 0.670852662
## 180  276     38       0        1 0.77018310 0.070449637 0.8842210 0.670852662
## 181  284     37       0        1 0.77018310 0.070449637 0.8842210 0.670852662
## 182  285     36       1        0 0.74878913 0.075873593 0.8688469 0.645321019
## 183  286     35       1        0 0.72739515 0.081222770 0.8529181 0.620345244
## 184  292     34       0        1 0.72739515 0.081222770 0.8529181 0.620345244
## 185  300     33       0        1 0.72739515 0.081222770 0.8529181 0.620345244
## 186  303     32       1        0 0.70466406 0.087207814 0.8360140 0.593951103
## 187  315     31       0        1 0.70466406 0.087207814 0.8360140 0.593951103
## 188  320     30       1        0 0.68117525 0.093566170 0.8182811 0.567041956
## 189  332     29       0        1 0.68117525 0.093566170 0.8182811 0.567041956
## 190  337     28       1        0 0.65684757 0.100386152 0.7996749 0.539530186
## 191  340     27       1        0 0.63251988 0.107246822 0.7804819 0.512608164
## 192  348     26       1        0 0.60819219 0.114194319 0.7607522 0.486226315
## 193  350     25       1        0 0.58386450 0.121272458 0.7405244 0.460346419
## 194  353     24       2        0 0.53520913 0.135995911 0.6986883 0.409980860
## 195  371     22       1        0 0.51088144 0.143733747 0.6771214 0.385455049
## 196  382     21       0        1 0.51088144 0.143733747 0.6771214 0.385455049
## 197  384     20       0        1 0.51088144 0.143733747 0.6771214 0.385455049
## 198  394     19       1        0 0.48399294 0.153568768 0.6539688 0.358196268
## 199  428     18       1        0 0.45710445 0.163863786 0.6302263 0.331538782
## 200  433     17       1        0 0.43021595 0.174722097 0.6059129 0.305465937
## 201  442     16       1        0 0.40332745 0.186264537 0.5810406 0.279968469
## 202  444     15       0        1 0.40332745 0.186264537 0.5810406 0.279968469
## 203  455     14       1        0 0.37451835 0.200471901 0.5547727 0.252831458
## 204  543     13       0        1 0.37451835 0.200471901 0.5547727 0.252831458
## 205  558     12       1        0 0.34330849 0.218551460 0.5268851 0.223693415
## 206  559     11       0        1 0.34330849 0.218551460 0.5268851 0.223693415
## 207  574     10       1        0 0.30897764 0.242643467 0.4971249 0.192038611
## 208  588      9       0        1 0.30897764 0.242643467 0.4971249 0.192038611
## 209  643      8       1        0 0.27035543 0.277007211 0.4652904 0.157089131
## 210  655      7       1        0 0.23173323 0.317084403 0.4314108 0.124475987
## 211  705      6       1        0 0.19311102 0.365890492 0.3955976 0.094267180
## 212  791      5       1        0 0.15448882 0.428807477 0.3580129 0.066664629
## 213  821      4       0        1 0.15448882 0.428807477 0.3580129 0.066664629
## 214  840      3       0        1 0.15448882 0.428807477 0.3580129 0.066664629
## 215  883      2       1        0 0.07724441 0.826967866 0.3906460 0.015273928
## 216 1010      1       0        1 0.07724441 0.826967866 0.3906460 0.015273928
##                   strata      ph.ecog
## 1      ph.ecog=Bedridden    Bedridden
## 2      ph.ecog=Bedridden    Bedridden
## 3      ph.ecog=Bedridden    Bedridden
## 4      ph.ecog=Bedridden    Bedridden
## 5      ph.ecog=Bedridden    Bedridden
## 6      ph.ecog=Bedridden    Bedridden
## 7      ph.ecog=Bedridden    Bedridden
## 8      ph.ecog=Bedridden    Bedridden
## 9      ph.ecog=Bedridden    Bedridden
## 10     ph.ecog=Bedridden    Bedridden
## 11     ph.ecog=Bedridden    Bedridden
## 12     ph.ecog=Bedridden    Bedridden
## 13     ph.ecog=Bedridden    Bedridden
## 14     ph.ecog=Bedridden    Bedridden
## 15     ph.ecog=Bedridden    Bedridden
## 16     ph.ecog=Bedridden    Bedridden
## 17     ph.ecog=Bedridden    Bedridden
## 18     ph.ecog=Bedridden    Bedridden
## 19     ph.ecog=Bedridden    Bedridden
## 20     ph.ecog=Bedridden    Bedridden
## 21     ph.ecog=Bedridden    Bedridden
## 22     ph.ecog=Bedridden    Bedridden
## 23     ph.ecog=Bedridden    Bedridden
## 24     ph.ecog=Bedridden    Bedridden
## 25     ph.ecog=Bedridden    Bedridden
## 26     ph.ecog=Bedridden    Bedridden
## 27     ph.ecog=Bedridden    Bedridden
## 28     ph.ecog=Bedridden    Bedridden
## 29     ph.ecog=Bedridden    Bedridden
## 30     ph.ecog=Bedridden    Bedridden
## 31     ph.ecog=Bedridden    Bedridden
## 32     ph.ecog=Bedridden    Bedridden
## 33     ph.ecog=Bedridden    Bedridden
## 34     ph.ecog=Bedridden    Bedridden
## 35     ph.ecog=Bedridden    Bedridden
## 36     ph.ecog=Bedridden    Bedridden
## 37     ph.ecog=Bedridden    Bedridden
## 38     ph.ecog=Bedridden    Bedridden
## 39     ph.ecog=Bedridden    Bedridden
## 40     ph.ecog=Bedridden    Bedridden
## 41     ph.ecog=Bedridden    Bedridden
## 42     ph.ecog=Bedridden    Bedridden
## 43     ph.ecog=Bedridden    Bedridden
## 44     ph.ecog=Bedridden    Bedridden
## 45     ph.ecog=Bedridden    Bedridden
## 46     ph.ecog=Bedridden    Bedridden
## 47     ph.ecog=Bedridden    Bedridden
## 48     ph.ecog=Bedridden    Bedridden
## 49     ph.ecog=Bedridden    Bedridden
## 50     ph.ecog=Bedridden    Bedridden
## 51    ph.ecog=Ambulatory   Ambulatory
## 52    ph.ecog=Ambulatory   Ambulatory
## 53    ph.ecog=Ambulatory   Ambulatory
## 54    ph.ecog=Ambulatory   Ambulatory
## 55    ph.ecog=Ambulatory   Ambulatory
## 56    ph.ecog=Ambulatory   Ambulatory
## 57    ph.ecog=Ambulatory   Ambulatory
## 58    ph.ecog=Ambulatory   Ambulatory
## 59    ph.ecog=Ambulatory   Ambulatory
## 60    ph.ecog=Ambulatory   Ambulatory
## 61    ph.ecog=Ambulatory   Ambulatory
## 62    ph.ecog=Ambulatory   Ambulatory
## 63    ph.ecog=Ambulatory   Ambulatory
## 64    ph.ecog=Ambulatory   Ambulatory
## 65    ph.ecog=Ambulatory   Ambulatory
## 66    ph.ecog=Ambulatory   Ambulatory
## 67    ph.ecog=Ambulatory   Ambulatory
## 68    ph.ecog=Ambulatory   Ambulatory
## 69    ph.ecog=Ambulatory   Ambulatory
## 70    ph.ecog=Ambulatory   Ambulatory
## 71    ph.ecog=Ambulatory   Ambulatory
## 72    ph.ecog=Ambulatory   Ambulatory
## 73    ph.ecog=Ambulatory   Ambulatory
## 74    ph.ecog=Ambulatory   Ambulatory
## 75    ph.ecog=Ambulatory   Ambulatory
## 76    ph.ecog=Ambulatory   Ambulatory
## 77    ph.ecog=Ambulatory   Ambulatory
## 78    ph.ecog=Ambulatory   Ambulatory
## 79    ph.ecog=Ambulatory   Ambulatory
## 80    ph.ecog=Ambulatory   Ambulatory
## 81    ph.ecog=Ambulatory   Ambulatory
## 82    ph.ecog=Ambulatory   Ambulatory
## 83    ph.ecog=Ambulatory   Ambulatory
## 84    ph.ecog=Ambulatory   Ambulatory
## 85    ph.ecog=Ambulatory   Ambulatory
## 86    ph.ecog=Ambulatory   Ambulatory
## 87    ph.ecog=Ambulatory   Ambulatory
## 88    ph.ecog=Ambulatory   Ambulatory
## 89    ph.ecog=Ambulatory   Ambulatory
## 90    ph.ecog=Ambulatory   Ambulatory
## 91    ph.ecog=Ambulatory   Ambulatory
## 92    ph.ecog=Ambulatory   Ambulatory
## 93    ph.ecog=Ambulatory   Ambulatory
## 94    ph.ecog=Ambulatory   Ambulatory
## 95    ph.ecog=Ambulatory   Ambulatory
## 96    ph.ecog=Ambulatory   Ambulatory
## 97    ph.ecog=Ambulatory   Ambulatory
## 98    ph.ecog=Ambulatory   Ambulatory
## 99    ph.ecog=Ambulatory   Ambulatory
## 100   ph.ecog=Ambulatory   Ambulatory
## 101   ph.ecog=Ambulatory   Ambulatory
## 102   ph.ecog=Ambulatory   Ambulatory
## 103   ph.ecog=Ambulatory   Ambulatory
## 104   ph.ecog=Ambulatory   Ambulatory
## 105   ph.ecog=Ambulatory   Ambulatory
## 106   ph.ecog=Ambulatory   Ambulatory
## 107   ph.ecog=Ambulatory   Ambulatory
## 108   ph.ecog=Ambulatory   Ambulatory
## 109   ph.ecog=Ambulatory   Ambulatory
## 110   ph.ecog=Ambulatory   Ambulatory
## 111   ph.ecog=Ambulatory   Ambulatory
## 112   ph.ecog=Ambulatory   Ambulatory
## 113   ph.ecog=Ambulatory   Ambulatory
## 114   ph.ecog=Ambulatory   Ambulatory
## 115   ph.ecog=Ambulatory   Ambulatory
## 116   ph.ecog=Ambulatory   Ambulatory
## 117   ph.ecog=Ambulatory   Ambulatory
## 118   ph.ecog=Ambulatory   Ambulatory
## 119   ph.ecog=Ambulatory   Ambulatory
## 120   ph.ecog=Ambulatory   Ambulatory
## 121   ph.ecog=Ambulatory   Ambulatory
## 122   ph.ecog=Ambulatory   Ambulatory
## 123   ph.ecog=Ambulatory   Ambulatory
## 124   ph.ecog=Ambulatory   Ambulatory
## 125   ph.ecog=Ambulatory   Ambulatory
## 126   ph.ecog=Ambulatory   Ambulatory
## 127   ph.ecog=Ambulatory   Ambulatory
## 128   ph.ecog=Ambulatory   Ambulatory
## 129   ph.ecog=Ambulatory   Ambulatory
## 130   ph.ecog=Ambulatory   Ambulatory
## 131   ph.ecog=Ambulatory   Ambulatory
## 132   ph.ecog=Ambulatory   Ambulatory
## 133   ph.ecog=Ambulatory   Ambulatory
## 134   ph.ecog=Ambulatory   Ambulatory
## 135   ph.ecog=Ambulatory   Ambulatory
## 136   ph.ecog=Ambulatory   Ambulatory
## 137   ph.ecog=Ambulatory   Ambulatory
## 138   ph.ecog=Ambulatory   Ambulatory
## 139   ph.ecog=Ambulatory   Ambulatory
## 140   ph.ecog=Ambulatory   Ambulatory
## 141   ph.ecog=Ambulatory   Ambulatory
## 142   ph.ecog=Ambulatory   Ambulatory
## 143   ph.ecog=Ambulatory   Ambulatory
## 144   ph.ecog=Ambulatory   Ambulatory
## 145   ph.ecog=Ambulatory   Ambulatory
## 146   ph.ecog=Ambulatory   Ambulatory
## 147   ph.ecog=Ambulatory   Ambulatory
## 148   ph.ecog=Ambulatory   Ambulatory
## 149   ph.ecog=Ambulatory   Ambulatory
## 150   ph.ecog=Ambulatory   Ambulatory
## 151   ph.ecog=Ambulatory   Ambulatory
## 152   ph.ecog=Ambulatory   Ambulatory
## 153   ph.ecog=Ambulatory   Ambulatory
## 154   ph.ecog=Ambulatory   Ambulatory
## 155 ph.ecog=Asymptomatic Asymptomatic
## 156 ph.ecog=Asymptomatic Asymptomatic
## 157 ph.ecog=Asymptomatic Asymptomatic
## 158 ph.ecog=Asymptomatic Asymptomatic
## 159 ph.ecog=Asymptomatic Asymptomatic
## 160 ph.ecog=Asymptomatic Asymptomatic
## 161 ph.ecog=Asymptomatic Asymptomatic
## 162 ph.ecog=Asymptomatic Asymptomatic
## 163 ph.ecog=Asymptomatic Asymptomatic
## 164 ph.ecog=Asymptomatic Asymptomatic
## 165 ph.ecog=Asymptomatic Asymptomatic
## 166 ph.ecog=Asymptomatic Asymptomatic
## 167 ph.ecog=Asymptomatic Asymptomatic
## 168 ph.ecog=Asymptomatic Asymptomatic
## 169 ph.ecog=Asymptomatic Asymptomatic
## 170 ph.ecog=Asymptomatic Asymptomatic
## 171 ph.ecog=Asymptomatic Asymptomatic
## 172 ph.ecog=Asymptomatic Asymptomatic
## 173 ph.ecog=Asymptomatic Asymptomatic
## 174 ph.ecog=Asymptomatic Asymptomatic
## 175 ph.ecog=Asymptomatic Asymptomatic
## 176 ph.ecog=Asymptomatic Asymptomatic
## 177 ph.ecog=Asymptomatic Asymptomatic
## 178 ph.ecog=Asymptomatic Asymptomatic
## 179 ph.ecog=Asymptomatic Asymptomatic
## 180 ph.ecog=Asymptomatic Asymptomatic
## 181 ph.ecog=Asymptomatic Asymptomatic
## 182 ph.ecog=Asymptomatic Asymptomatic
## 183 ph.ecog=Asymptomatic Asymptomatic
## 184 ph.ecog=Asymptomatic Asymptomatic
## 185 ph.ecog=Asymptomatic Asymptomatic
## 186 ph.ecog=Asymptomatic Asymptomatic
## 187 ph.ecog=Asymptomatic Asymptomatic
## 188 ph.ecog=Asymptomatic Asymptomatic
## 189 ph.ecog=Asymptomatic Asymptomatic
## 190 ph.ecog=Asymptomatic Asymptomatic
## 191 ph.ecog=Asymptomatic Asymptomatic
## 192 ph.ecog=Asymptomatic Asymptomatic
## 193 ph.ecog=Asymptomatic Asymptomatic
## 194 ph.ecog=Asymptomatic Asymptomatic
## 195 ph.ecog=Asymptomatic Asymptomatic
## 196 ph.ecog=Asymptomatic Asymptomatic
## 197 ph.ecog=Asymptomatic Asymptomatic
## 198 ph.ecog=Asymptomatic Asymptomatic
## 199 ph.ecog=Asymptomatic Asymptomatic
## 200 ph.ecog=Asymptomatic Asymptomatic
## 201 ph.ecog=Asymptomatic Asymptomatic
## 202 ph.ecog=Asymptomatic Asymptomatic
## 203 ph.ecog=Asymptomatic Asymptomatic
## 204 ph.ecog=Asymptomatic Asymptomatic
## 205 ph.ecog=Asymptomatic Asymptomatic
## 206 ph.ecog=Asymptomatic Asymptomatic
## 207 ph.ecog=Asymptomatic Asymptomatic
## 208 ph.ecog=Asymptomatic Asymptomatic
## 209 ph.ecog=Asymptomatic Asymptomatic
## 210 ph.ecog=Asymptomatic Asymptomatic
## 211 ph.ecog=Asymptomatic Asymptomatic
## 212 ph.ecog=Asymptomatic Asymptomatic
## 213 ph.ecog=Asymptomatic Asymptomatic
## 214 ph.ecog=Asymptomatic Asymptomatic
## 215 ph.ecog=Asymptomatic Asymptomatic
## 216 ph.ecog=Asymptomatic Asymptomatic
##################################
# Plotting the Kaplan-Meier survival curves
# using the Factor Variable
##################################
SurvivalTimeInWeek.KaplanMeier.ByGroup <- ggsurvplot(DBP.Analysis.Filtered.KaplanMeierEstimates,
                                                     title = "Kaplan-Meier Survival Curve (ECOG Score)",
                                                     pval = FALSE,
                                                     conf.int = TRUE,
                                                     conf.int.style = "ribbon",
                                                     xlab = "Time (Days)",
                                                     ylab="Estimated Survival Probability",
                                                     break.time.by = 100,
                                                     ggtheme = theme_bw(),
                                                     risk.table = "abs_pct",
                                                     risk.table.title="Number at Risk (Survival Probability)",
                                                     risk.table.y.text.col = FALSE,
                                                     risk.table.y.text = TRUE,
                                                     fontsize = 3,
                                                     ncensor.plot = FALSE,
                                                     surv.median.line = "hv",
                                                     legend.labs = c("Bedridden", "Ambulatory", "Asymptomatic"),
                                                     palette = c("#00CC66","#3259A0","#FF5050"))

ggpar(SurvivalTimeInWeek.KaplanMeier.ByGroup,
      font.title = c(14,"bold"),
      font.x = c(12,"bold"),
      font.y = c(12,"bold"),
      font.legend=c(12),
      font.xtickslab=c(9,"black"),
      font.ytickslab=c(9,"black"))

1.4.3 Log Rank Test


Log Rank Test evaluates the null hypothesis of no difference in survival between two or more independent groups by comparing the entire survival experience. The method involves generating a sequential list of time values corresponding to an event or censoring from two or more independent groups; determining the counts of event-free observations, event and expected events for each time value; calculating the Chi-Square test statistic based on these counts; and evaluating the determined test statistic against the rejection region.

Code Chunk | Output
##################################
# Conducting the Log Rank Test
# between the Kaplan-Meier survival estimates
# using the Factor Variable
##################################
(DBP.Analysis.Filtered.LogRankTest <- survdiff(Surv(time, status) ~ ph.ecog, data = DBP.Analysis.Filtered))
## Call:
## survdiff(formula = Surv(time, status) ~ ph.ecog, data = DBP.Analysis.Filtered)
## 
##                        N Observed Expected (O-E)^2/E (O-E)^2/V
## ph.ecog=Bedridden     51       45     26.3   13.2582   15.9641
## ph.ecog=Ambulatory   113       82     83.5    0.0279    0.0573
## ph.ecog=Asymptomatic  63       37     54.2    5.4331    8.2119
## 
##  Chisq= 19  on 2 degrees of freedom, p= 8e-05
##################################
# Conducting the Post-Hoc Test
# between the Kaplan-Meier survival estimates
# using the Factor Variable
#################################
(DBP.Analysis.Filtered.LogRankTest.PosthocTest <- survminer::pairwise_survdiff(Surv(time, status) ~ ph.ecog, data = DBP.Analysis.Filtered))
## 
##  Pairwise comparisons using Log-Rank test 
## 
## data:  DBP.Analysis.Filtered and ph.ecog 
## 
##              Bedridden Ambulatory
## Ambulatory   0.0039    -         
## Asymptomatic 9e-05     0.0630    
## 
## P value adjustment method: BH
##################################
# Plotting the Kaplan-Meier survival curves
# using the Factor Variable
##################################
SurvivalTimeInWeek.KaplanMeier.ByGroup <- ggsurvplot(DBP.Analysis.Filtered.KaplanMeierEstimates,
                                                     title = "Kaplan-Meier Survival Curve (ECOG Score)",
                                                     pval = TRUE,
                                                     conf.int = TRUE,
                                                     conf.int.style = "ribbon",
                                                     xlab = "Time (Days)",
                                                     ylab="Estimated Survival Probability",
                                                     break.time.by = 100,
                                                     ggtheme = theme_bw(),
                                                     risk.table = "abs_pct",
                                                     risk.table.title="Number at Risk (Survival Probability)",
                                                     risk.table.y.text.col = FALSE,
                                                     risk.table.y.text = TRUE,
                                                     fontsize = 3,
                                                     ncensor.plot = FALSE,
                                                     surv.median.line = "hv",
                                                     legend.labs = c("Bedridden", "Ambulatory", "Asymptomatic"),
                                                     palette = c("#00CC66","#3259A0","#FF5050"))

ggpar(SurvivalTimeInWeek.KaplanMeier.ByGroup,
      font.title = c(14,"bold"),
      font.x = c(12,"bold"),
      font.y = c(12,"bold"),
      font.legend=c(12),
      font.xtickslab=c(9,"black"),
      font.ytickslab=c(9,"black"))

1.5 Model Development Summary


Cox Proportional Hazards Regression examines the relationship between a hazard function and a set of covariates by assuming that predictors act multiplicatively on the hazard function without any explicit assumption of its distributional form. The model is semi-parametric because while the baseline hazard can take any form, the covariates enter the model linearly.

Concordance Index is a rank correlation measure between a predictor and a possibly censored outcome with an event or censoring indicator. In survival analysis, a pair of patients is called concordant if the risk of the event predicted by a model is lower for the patient who experiences the event at a later time point. The concordance probability (C-index) is the frequency of concordant pairs among all pairs of subjects which can be used to measure and compare the discrimination power of risk prediction models.

Residual Analysis for Model Assumption Diagnostics assesses whether a fitted Cox Proportional Hazards Regression model adequately describes the data using various residuals to test the proportional hazards assumption, examine influential observations (or outliers) and detect nonlinearity in the relationship between the log hazard and the covariates. Schoenfeld residuals are calculated by regressing the scaled and weighted Martingale residuals on the model covariates. These help evaluate the proportional hazards assumption by examining the relationship between the residuals and time for each covariate. A significant correlation between Schoenfeld residuals and time suggests a violation of the model assumptions. Deviance residuals are derived from the log partial likelihood estimation during regression. These measure the difference between the observed event status and the predicted event probability. Deviance residuals are more sensitive to the shape of the hazard function and can help identify departures from the model assumptions.

Cox proportional hazards regression analysis involving the response variable time, factor variable ph.ecog and covariate variables sex and age showed that :

[A] A cox proportional hazards regression model applied on the response variable time and factor variable ph.ecog which includes the covariate variable sex but excludes the covariate variable age was determined with the most optimal fit during stepwise variable selection. Furthermore, the aforementioned model was considered the most appropriate as the final survival model since the addition of the covariate variable sex significantly improved model fit (p<0.001, Likelihood Ratio Test). However, the further inclusion of an interaction term ph.ecog * sex into the model did not show any significant improvement to model fit (p=0.789, Likelihood Ratio Test).

[B] Using the final survival model controlled for sex, association between ph.ecog and survival time time was statistically significant with:
     [B.1] An estimated hazard ratio of 0.58 (95% CI 0.40, 0.84; p=0.004, Cox Proportional Hazards Model Wald Test) for ph.ecog=Ambulatory (lower hazard and higher survival rate for advanced lung cancer patients with physician-rated ECOG score = 1) relative to ph.ecog=Bedridden (higher hazard and lower survival rate for advanced lung cancer patients with physician-rated ECOG score = 2 or 3)
     [B.2] An estimated hazard ratio of 0.38 (95% CI 0.25, 0.59; p<0.001, Cox Proportional Hazards Model Wald Test) for ph.ecog=Asymptomatic (lower hazard and higher survival rate for advanced lung cancer patients with physician-rated ECOG score = 0) relative to ph.ecog=Bedridden (higher hazard and lower survival rate for advanced lung cancer patients with physician-rated ECOG score = 2 or 3)

[C] Using the final survival model controlled for ph.ecog, association between sex and survival time time was statistically significant with an estimated hazard ratio of 0.58 (95% CI 0.42, 0.80; p=0.001, Cox Proportional Hazards Model Wald Test) for sex=Female (lower hazard and higher survival rate for advanced lung cancer patients who are females) relative to sex=Male (higher hazard and lower survival rate for advanced lung cancer patients who are males).

[D] The estimated Harrel’s concordance index (proportion of advanced lung cancer patients that the model can correctly order in terms of survival times when adjusted for censoring) for the final survival model was determined to be relatively satisfactory at 0.64 (optimistic) and 0.63 (optimism-corrected after a 500-cycle internal bootstrap validation).

[E] The scaled Schoenfield residuals showed random patterns when plotted against time indicating no violation of the proportional hazards assumption. The proportional hazards assumption was further supported by the non-significant relationship between the scaled Schoenfield residuals and time based from the global (p=0.1514) and individual (p=0.2188 for ph.ecpg, 0.1001 for sex ) statistical test results.

[F] The deviance residuals did not show any severely influential observations when plotted against the observations and the dfbeta residuals were reasonably symmetrical when plotted against the observations - all indicating a fairly good model fit for the final survival model. Due to the absence of a numeric covariate, no fitted line with lowess function of the martingale residuals obtained for the null cox model was obtained.

1.5.1 Univariate Cox Proportional Hazards Model


Code Chunk | Output
##################################
# Formulating a Univariate Cox Proportional Hazards Model
# independently for the Factor Variable
##################################
(DBP.Analysis.UnivariateCoxPH.PhEcog <- coxph(Surv(time, status) ~ ph.ecog, data = DBP.Analysis.Filtered))
## Call:
## coxph(formula = Surv(time, status) ~ ph.ecog, data = DBP.Analysis.Filtered)
## 
##                        coef exp(coef) se(coef)      z        p
## ph.ecogAmbulatory   -0.5628    0.5696   0.1863 -3.021  0.00252
## ph.ecogAsymptomatic -0.9309    0.3942   0.2235 -4.166 3.11e-05
## 
## Likelihood ratio test=17.33  on 2 df, p=0.0001722
## n= 227, number of events= 164
summary(DBP.Analysis.UnivariateCoxPH.PhEcog)
## Call:
## coxph(formula = Surv(time, status) ~ ph.ecog, data = DBP.Analysis.Filtered)
## 
##   n= 227, number of events= 164 
## 
##                        coef exp(coef) se(coef)      z Pr(>|z|)    
## ph.ecogAmbulatory   -0.5628    0.5696   0.1863 -3.021  0.00252 ** 
## ph.ecogAsymptomatic -0.9309    0.3942   0.2235 -4.166 3.11e-05 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
##                     exp(coef) exp(-coef) lower .95 upper .95
## ph.ecogAmbulatory      0.5696      1.755    0.3954    0.8207
## ph.ecogAsymptomatic    0.3942      2.537    0.2544    0.6108
## 
## Concordance= 0.604  (se = 0.024 )
## Likelihood ratio test= 17.33  on 2 df,   p=2e-04
## Wald test            = 18.17  on 2 df,   p=1e-04
## Score (logrank) test = 19  on 2 df,   p=7e-05
tbl_regression(DBP.Analysis.UnivariateCoxPH.PhEcog,
               exponentiate = TRUE)
Characteristic HR1 95% CI1 p-value
ph.ecog


    Bedridden
    Ambulatory 0.57 0.40, 0.82 0.003
    Asymptomatic 0.39 0.25, 0.61 <0.001
1 HR = Hazard Ratio, CI = Confidence Interval
(ggforest(DBP.Analysis.UnivariateCoxPH.PhEcog,
          data=DBP.Analysis.Filtered,
          main = "",
          fontsize = 0.9))

##################################
# Plotting the Kaplan-Meier survival curves
# for the formulated Univariate Cox Proportional Hazards Model
# involving the Factor Variable
##################################
DBP.Analysis.UnivariateCoxPH.PhEcog.KaplanMeierEstimates <- survfit(DBP.Analysis.UnivariateCoxPH.PhEcog, data = DBP.Analysis.Filtered)

SurvivalTimeInWeek.KaplanMeier.UnivariateCoxPH.PhEcog <- ggsurvplot(DBP.Analysis.UnivariateCoxPH.PhEcog.KaplanMeierEstimates,
                                                     title = "Kaplan-Meier Survival Curves (CoxPH Model : Survival ~ ECOG Score)",
                                                     pval = FALSE,
                                                     conf.int = TRUE,
                                                     conf.int.style = "ribbon",
                                                     xlab = "Time (Days)",
                                                     ylab="Estimated Survival Probability",
                                                     break.time.by = 100,
                                                     ggtheme = theme_bw(),
                                                     risk.table = "abs_pct",
                                                     risk.table.title="Number at Risk (Survival Probability)",
                                                     risk.table.y.text.col = FALSE,
                                                     risk.table.y.text = TRUE,
                                                     fontsize = 3,
                                                     ncensor.plot = FALSE,
                                                     surv.median.line = "hv",
                                                     palette = c("#000000"))

ggpar(SurvivalTimeInWeek.KaplanMeier.UnivariateCoxPH.PhEcog,
      font.title = c(14,"bold"),
      font.x = c(12,"bold"),
      font.y = c(12,"bold"),
      font.legend=c(12),
      font.xtickslab=c(9,"black"),
      font.ytickslab=c(9,"black"))

##################################
# Formulating a Univariate Cox Proportional Hazards Model
# independently for the Covariate Variable
##################################
(DBP.Analysis.UnivariateCoxPH.Sex <- coxph(Surv(time, status) ~ sex, data = DBP.Analysis.Filtered))
## Call:
## coxph(formula = Surv(time, status) ~ sex, data = DBP.Analysis.Filtered)
## 
##              coef exp(coef) se(coef)      z       p
## sexFemale -0.5237    0.5923   0.1674 -3.128 0.00176
## 
## Likelihood ratio test=10.3  on 1 df, p=0.001331
## n= 227, number of events= 164
summary(DBP.Analysis.UnivariateCoxPH.Sex)
## Call:
## coxph(formula = Surv(time, status) ~ sex, data = DBP.Analysis.Filtered)
## 
##   n= 227, number of events= 164 
## 
##              coef exp(coef) se(coef)      z Pr(>|z|)   
## sexFemale -0.5237    0.5923   0.1674 -3.128  0.00176 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
##           exp(coef) exp(-coef) lower .95 upper .95
## sexFemale    0.5923      1.688    0.4266    0.8224
## 
## Concordance= 0.577  (se = 0.021 )
## Likelihood ratio test= 10.3  on 1 df,   p=0.001
## Wald test            = 9.78  on 1 df,   p=0.002
## Score (logrank) test = 10.01  on 1 df,   p=0.002
tbl_regression(DBP.Analysis.UnivariateCoxPH.Sex,
               exponentiate = TRUE)
Characteristic HR1 95% CI1 p-value
sex


    Male
    Female 0.59 0.43, 0.82 0.002
1 HR = Hazard Ratio, CI = Confidence Interval
(ggforest(DBP.Analysis.UnivariateCoxPH.Sex,
          data=DBP.Analysis.Filtered,
          main = "",
          fontsize = 0.9))

##################################
# Plotting the Kaplan-Meier survival curves
# for the formulated Univariate Cox Proportional Hazards Model
# involving the Covariate Variable
##################################
DBP.Analysis.UnivariateCoxPH.Sex.KaplanMeierEstimates <- survfit(DBP.Analysis.UnivariateCoxPH.Sex, data = DBP.Analysis.Filtered)

SurvivalTimeInWeek.KaplanMeier.UnivariateCoxPH.Sex <- ggsurvplot(DBP.Analysis.UnivariateCoxPH.Sex.KaplanMeierEstimates,
                                                     title = "Kaplan-Meier Survival Curves (CoxPH Model : Survival ~ Sex)",
                                                     pval = FALSE,
                                                     conf.int = TRUE,
                                                     conf.int.style = "ribbon",
                                                     xlab = "Time (Days)",
                                                     ylab="Estimated Survival Probability",
                                                     break.time.by = 100,
                                                     ggtheme = theme_bw(),
                                                     risk.table = "abs_pct",
                                                     risk.table.title="Number at Risk (Survival Probability)",
                                                     risk.table.y.text.col = FALSE,
                                                     risk.table.y.text = TRUE,
                                                     fontsize = 3,
                                                     ncensor.plot = FALSE,
                                                     surv.median.line = "hv",
                                                     palette = c("#000000"))

ggpar(SurvivalTimeInWeek.KaplanMeier.UnivariateCoxPH.Sex,
      font.title = c(14,"bold"),
      font.x = c(12,"bold"),
      font.y = c(12,"bold"),
      font.legend=c(12),
      font.xtickslab=c(9,"black"),
      font.ytickslab=c(9,"black"))

##################################
# Formulating a Univariate Cox Proportional Hazards Model
# independently for the Covariate Variable
##################################
(DBP.Analysis.UnivariateCoxPH.Age <- coxph(Surv(time, status) ~ age, data = DBP.Analysis.Filtered))
## Call:
## coxph(formula = Surv(time, status) ~ age, data = DBP.Analysis.Filtered)
## 
##         coef exp(coef) se(coef)     z      p
## age 0.018969  1.019150 0.009231 2.055 0.0399
## 
## Likelihood ratio test=4.33  on 1 df, p=0.03754
## n= 227, number of events= 164
summary(DBP.Analysis.UnivariateCoxPH.Age)
## Call:
## coxph(formula = Surv(time, status) ~ age, data = DBP.Analysis.Filtered)
## 
##   n= 227, number of events= 164 
## 
##         coef exp(coef) se(coef)     z Pr(>|z|)  
## age 0.018969  1.019150 0.009231 2.055   0.0399 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
##     exp(coef) exp(-coef) lower .95 upper .95
## age     1.019     0.9812     1.001     1.038
## 
## Concordance= 0.551  (se = 0.025 )
## Likelihood ratio test= 4.33  on 1 df,   p=0.04
## Wald test            = 4.22  on 1 df,   p=0.04
## Score (logrank) test = 4.24  on 1 df,   p=0.04
tbl_regression(DBP.Analysis.UnivariateCoxPH.Age,
               exponentiate = TRUE)
Characteristic HR1 95% CI1 p-value
age 1.02 1.00, 1.04 0.040
1 HR = Hazard Ratio, CI = Confidence Interval
(ggforest(DBP.Analysis.UnivariateCoxPH.Age,
          data=DBP.Analysis.Filtered,
          main = "",
          fontsize = 0.9))

##################################
# Plotting the Kaplan-Meier survival curves
# for the formulated Univariate Cox Proportional Hazards Model
# involving the Covariate Variable
##################################
DBP.Analysis.UnivariateCoxPH.Age.KaplanMeierEstimates <- survfit(DBP.Analysis.UnivariateCoxPH.Age, data = DBP.Analysis.Filtered)

SurvivalTimeInWeek.KaplanMeier.UnivariateCoxPH.Age <- ggsurvplot(DBP.Analysis.UnivariateCoxPH.Age.KaplanMeierEstimates,
                                                     title = "Kaplan-Meier Survival Curves (CoxPH Model : Survival ~ Age)",
                                                     pval = FALSE,
                                                     conf.int = TRUE,
                                                     conf.int.style = "ribbon",
                                                     xlab = "Time (Days)",
                                                     ylab="Estimated Survival Probability",
                                                     break.time.by = 100,
                                                     ggtheme = theme_bw(),
                                                     risk.table = "abs_pct",
                                                     risk.table.title="Number at Risk (Survival Probability)",
                                                     risk.table.y.text.col = FALSE,
                                                     risk.table.y.text = TRUE,
                                                     fontsize = 3,
                                                     ncensor.plot = FALSE,
                                                     surv.median.line = "hv",
                                                     palette = c("#000000"))

ggpar(SurvivalTimeInWeek.KaplanMeier.UnivariateCoxPH.Age,
      font.title = c(14,"bold"),
      font.x = c(12,"bold"),
      font.y = c(12,"bold"),
      font.legend=c(12),
      font.xtickslab=c(9,"black"),
      font.ytickslab=c(9,"black"))

##################################
# Formulating a Univariate Cox Proportional Hazards Model
# individually for the Factor and Covariate Variables
##################################
tbl_survfit(
  list(survfit(Surv(time, status) ~ 1, data = DBP.Analysis.Filtered),
    survfit(Surv(time, status) ~ ph.ecog, data = DBP.Analysis.Filtered),
    survfit(Surv(time, status) ~ sex, data = DBP.Analysis.Filtered),
        survfit(Surv(time, status) ~ age, data = DBP.Analysis.Filtered)),
  probs = 0.5,
  label_header = "**Median Survival**") %>%
  add_n() %>%
  add_nevent()
Characteristic N Event N Median Survival
Overall 227 164 310 (285, 363)
ph.ecog 227 164
    Bedridden

183 (153, 288)
    Ambulatory

306 (268, 429)
    Asymptomatic

394 (348, 574)
sex 227 164
    Male

270 (218, 320)
    Female

426 (348, 550)
age 227 164
    39

— (—, —)
    40

132 (—, —)
    41

— (—, —)
    42

— (—, —)
    43

— (—, —)
    44

268 (181, —)
    45

— (—, —)
    46

320 (—, —)
    47

353 (—, —)
    48

419 (223, —)
    49

147 (81, —)
    50

239 (131, —)
    51

705 (—, —)
    52

179 (81, —)
    53

226 (202, —)
    54

491 (163, —)
    55

308 (156, —)
    56

363 (197, —)
    57

245 (170, —)
    58

371 (348, —)
    59

433 (293, —)
    60

387 (145, —)
    61

166 (147, —)
    62

291 (105, —)
    63

519 (189, —)
    64

477 (110, —)
    65

174 (60, —)
    66

288 (156, —)
    67

230 (208, —)
    68

455 (310, —)
    69

450 (329, —)
    70

460 (229, —)
    71

332 (284, —)
    72

270 (54, —)
    73

164 (59, —)
    74

306 (93, —)
    75

397 (201, —)
    76

116 (95, —)
    77

— (—, —)
    80

323 (283, —)
    81

11 (—, —)
    82

31 (—, —)

1.5.2 Multivariate Cox Proportional Hazards Model


Code Chunk | Output
##################################
# Formulating a Multivariate Cox Proportional Hazards Model
# with both the Factor and Covariate Variables
##################################
(DBP.Analysis.MultivariateCoxPH.PhEcogSexAge <- coxph(Surv(time, status) ~ ph.ecog + sex + age, data = DBP.Analysis.Filtered))
## Call:
## coxph(formula = Surv(time, status) ~ ph.ecog + sex + age, data = DBP.Analysis.Filtered)
## 
##                          coef exp(coef)  se(coef)      z       p
## ph.ecogAmbulatory   -0.506291  0.602727  0.188454 -2.687 0.00722
## ph.ecogAsymptomatic -0.915752  0.400215  0.227042 -4.033 5.5e-05
## sexFemale           -0.551322  0.576188  0.167987 -3.282 0.00103
## age                  0.011031  1.011092  0.009297  1.186 0.23544
## 
## Likelihood ratio test=30.08  on 4 df, p=4.704e-06
## n= 227, number of events= 164
summary(DBP.Analysis.MultivariateCoxPH.PhEcogSexAge)
## Call:
## coxph(formula = Surv(time, status) ~ ph.ecog + sex + age, data = DBP.Analysis.Filtered)
## 
##   n= 227, number of events= 164 
## 
##                          coef exp(coef)  se(coef)      z Pr(>|z|)    
## ph.ecogAmbulatory   -0.506291  0.602727  0.188454 -2.687  0.00722 ** 
## ph.ecogAsymptomatic -0.915752  0.400215  0.227042 -4.033  5.5e-05 ***
## sexFemale           -0.551322  0.576188  0.167987 -3.282  0.00103 ** 
## age                  0.011031  1.011092  0.009297  1.186  0.23544    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
##                     exp(coef) exp(-coef) lower .95 upper .95
## ph.ecogAmbulatory      0.6027      1.659    0.4166    0.8720
## ph.ecogAsymptomatic    0.4002      2.499    0.2565    0.6245
## sexFemale              0.5762      1.736    0.4145    0.8009
## age                    1.0111      0.989    0.9928    1.0297
## 
## Concordance= 0.637  (se = 0.025 )
## Likelihood ratio test= 30.08  on 4 df,   p=5e-06
## Wald test            = 29.77  on 4 df,   p=5e-06
## Score (logrank) test = 30.94  on 4 df,   p=3e-06
tbl_regression(DBP.Analysis.MultivariateCoxPH.PhEcogSexAge,
               exponentiate = TRUE)
Characteristic HR1 95% CI1 p-value
ph.ecog


    Bedridden
    Ambulatory 0.60 0.42, 0.87 0.007
    Asymptomatic 0.40 0.26, 0.62 <0.001
sex


    Male
    Female 0.58 0.41, 0.80 0.001
age 1.01 0.99, 1.03 0.2
1 HR = Hazard Ratio, CI = Confidence Interval
(DBP.Analysis.MultivariateCoxPH.DBP.Analysis.MultivariateCoxPH.PhEcogSexAge.ForestPlot <- ggforest(DBP.Analysis.MultivariateCoxPH.PhEcogSexAge,
          data=DBP.Analysis.Filtered,
          main = "",
          fontsize = 0.9))

##################################
# Plotting the Kaplan-Meier survival curves
# for the formulated Multivariate Cox Proportional Hazards Model
# involving the Factor and Covariate variables
##################################
DBP.Analysis.MultivariateCoxPH.PhEcogSexAge.KaplanMeierEstimates <- survfit(DBP.Analysis.MultivariateCoxPH.PhEcogSexAge , data = DBP.Analysis.Filtered)

SurvivalTimeInWeek.KaplanMeier.MultivariateCoxPH.PhEcogSexAge <- ggsurvplot(DBP.Analysis.MultivariateCoxPH.PhEcogSexAge.KaplanMeierEstimates,
                                                     title = "Kaplan-Meier Survival Curves (CoxPH Model : Survival ~ ECOG Score + Sex + Age)",
                                                     pval = FALSE,
                                                     conf.int = TRUE,
                                                     conf.int.style = "ribbon",
                                                     xlab = "Time (Days)",
                                                     ylab="Estimated Survival Probability",
                                                     break.time.by = 100,
                                                     ggtheme = theme_bw(),
                                                     risk.table = "abs_pct",
                                                     risk.table.title="Number at Risk (Survival Probability)",
                                                     risk.table.y.text.col = FALSE,
                                                     risk.table.y.text = TRUE,
                                                     fontsize = 3,
                                                     ncensor.plot = FALSE,
                                                     surv.median.line = "hv",
                                                     palette = c("#000000"))

ggpar(SurvivalTimeInWeek.KaplanMeier.MultivariateCoxPH.PhEcogSexAge,
      font.title = c(14,"bold"),
      font.x = c(12,"bold"),
      font.y = c(12,"bold"),
      font.legend=c(12),
      font.xtickslab=c(9,"black"),
      font.ytickslab=c(9,"black"))

##################################
# Formulating a Multivariate Cox Proportional Hazards Model
# with both the Factor and Covariate Variables
# including their interaction
##################################
(DBP.Analysis.MultivariateCoxPH.PhEcogSexAge.WithInteraction <- coxph(Surv(time, status) ~ ph.ecog + sex + age + ph.ecog*sex*age, data = DBP.Analysis.Filtered))
## Call:
## coxph(formula = Surv(time, status) ~ ph.ecog + sex + age + ph.ecog * 
##     sex * age, data = DBP.Analysis.Filtered)
## 
##                                         coef  exp(coef)   se(coef)      z
## ph.ecogAmbulatory                  2.430e+00  1.136e+01  2.064e+00  1.177
## ph.ecogAsymptomatic               -1.392e+00  2.486e-01  2.547e+00 -0.546
## sexFemale                          7.319e+00  1.509e+03  2.746e+00  2.665
## age                                4.669e-02  1.048e+00  2.842e-02  1.643
## ph.ecogAmbulatory:sexFemale       -7.406e+00  6.073e-04  3.180e+00 -2.329
## ph.ecogAsymptomatic:sexFemale     -7.486e+00  5.610e-04  4.250e+00 -1.761
## ph.ecogAmbulatory:age             -4.524e-02  9.558e-01  3.178e-02 -1.424
## ph.ecogAsymptomatic:age            8.315e-03  1.008e+00  3.895e-02  0.213
## sexFemale:age                     -1.151e-01  8.912e-01  4.139e-02 -2.782
## ph.ecogAmbulatory:sexFemale:age    1.065e-01  1.112e+00  4.896e-02  2.176
## ph.ecogAsymptomatic:sexFemale:age  1.102e-01  1.116e+00  6.622e-02  1.664
##                                        p
## ph.ecogAmbulatory                 0.2390
## ph.ecogAsymptomatic               0.5848
## sexFemale                         0.0077
## age                               0.1004
## ph.ecogAmbulatory:sexFemale       0.0199
## ph.ecogAsymptomatic:sexFemale     0.0782
## ph.ecogAmbulatory:age             0.1545
## ph.ecogAsymptomatic:age           0.8309
## sexFemale:age                     0.0054
## ph.ecogAmbulatory:sexFemale:age   0.0295
## ph.ecogAsymptomatic:sexFemale:age 0.0961
## 
## Likelihood ratio test=42.43  on 11 df, p=1.362e-05
## n= 227, number of events= 164
summary(DBP.Analysis.MultivariateCoxPH.PhEcogSexAge.WithInteraction)
## Call:
## coxph(formula = Surv(time, status) ~ ph.ecog + sex + age + ph.ecog * 
##     sex * age, data = DBP.Analysis.Filtered)
## 
##   n= 227, number of events= 164 
## 
##                                         coef  exp(coef)   se(coef)      z
## ph.ecogAmbulatory                  2.430e+00  1.136e+01  2.064e+00  1.177
## ph.ecogAsymptomatic               -1.392e+00  2.486e-01  2.547e+00 -0.546
## sexFemale                          7.319e+00  1.509e+03  2.746e+00  2.665
## age                                4.669e-02  1.048e+00  2.842e-02  1.643
## ph.ecogAmbulatory:sexFemale       -7.406e+00  6.073e-04  3.180e+00 -2.329
## ph.ecogAsymptomatic:sexFemale     -7.486e+00  5.610e-04  4.250e+00 -1.761
## ph.ecogAmbulatory:age             -4.524e-02  9.558e-01  3.178e-02 -1.424
## ph.ecogAsymptomatic:age            8.315e-03  1.008e+00  3.895e-02  0.213
## sexFemale:age                     -1.151e-01  8.912e-01  4.139e-02 -2.782
## ph.ecogAmbulatory:sexFemale:age    1.065e-01  1.112e+00  4.896e-02  2.176
## ph.ecogAsymptomatic:sexFemale:age  1.102e-01  1.116e+00  6.622e-02  1.664
##                                   Pr(>|z|)   
## ph.ecogAmbulatory                   0.2390   
## ph.ecogAsymptomatic                 0.5848   
## sexFemale                           0.0077 **
## age                                 0.1004   
## ph.ecogAmbulatory:sexFemale         0.0199 * 
## ph.ecogAsymptomatic:sexFemale       0.0782 . 
## ph.ecogAmbulatory:age               0.1545   
## ph.ecogAsymptomatic:age             0.8309   
## sexFemale:age                       0.0054 **
## ph.ecogAmbulatory:sexFemale:age     0.0295 * 
## ph.ecogAsymptomatic:sexFemale:age   0.0961 . 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
##                                   exp(coef) exp(-coef) lower .95 upper .95
## ph.ecogAmbulatory                 1.136e+01  8.804e-02 1.989e-01 6.488e+02
## ph.ecogAsymptomatic               2.486e-01  4.022e+00 1.688e-03 3.663e+01
## sexFemale                         1.509e+03  6.627e-04 6.935e+00 3.284e+05
## age                               1.048e+00  9.544e-01 9.910e-01 1.108e+00
## ph.ecogAmbulatory:sexFemale       6.073e-04  1.647e+03 1.192e-06 3.095e-01
## ph.ecogAsymptomatic:sexFemale     5.610e-04  1.782e+03 1.352e-07 2.327e+00
## ph.ecogAmbulatory:age             9.558e-01  1.046e+00 8.981e-01 1.017e+00
## ph.ecogAsymptomatic:age           1.008e+00  9.917e-01 9.342e-01 1.088e+00
## sexFemale:age                     8.912e-01  1.122e+00 8.218e-01 9.665e-01
## ph.ecogAmbulatory:sexFemale:age   1.112e+00  8.989e-01 1.011e+00 1.224e+00
## ph.ecogAsymptomatic:sexFemale:age 1.116e+00  8.957e-01 9.806e-01 1.271e+00
## 
## Concordance= 0.662  (se = 0.024 )
## Likelihood ratio test= 42.43  on 11 df,   p=1e-05
## Wald test            = 41.85  on 11 df,   p=2e-05
## Score (logrank) test = 47.09  on 11 df,   p=2e-06
tbl_regression(DBP.Analysis.MultivariateCoxPH.PhEcogSexAge.WithInteraction,
               exponentiate = TRUE)
Characteristic HR1 95% CI1 p-value
ph.ecog


    Bedridden
    Ambulatory 11.4 0.20, 649 0.2
    Asymptomatic 0.25 0.00, 36.6 0.6
sex


    Male
    Female 1,509 6.93, 328,387 0.008
age 1.05 0.99, 1.11 0.10
ph.ecog * sex


    Ambulatory * Female 0.00 0.00, 0.31 0.020
    Asymptomatic * Female 0.00 0.00, 2.33 0.078
ph.ecog * age


    Ambulatory * age 0.96 0.90, 1.02 0.2
    Asymptomatic * age 1.01 0.93, 1.09 0.8
sex * age


    Female * age 0.89 0.82, 0.97 0.005
ph.ecog * sex * age


    Ambulatory * Female * age 1.11 1.01, 1.22 0.030
    Asymptomatic * Female * age 1.12 0.98, 1.27 0.10
1 HR = Hazard Ratio, CI = Confidence Interval
(DBP.Analysis.MultivariateCoxPH.PhEcogSexAge.WithInteraction.ForestPlot <- ggforest(DBP.Analysis.MultivariateCoxPH.PhEcogSexAge.WithInteraction,
          data=DBP.Analysis.Filtered,
          main = "",
          fontsize = 0.9))

##################################
# Plotting the Kaplan-Meier survival curves
# for the formulated Multivariate Cox Proportional Hazards Model
# involving the Factor and Covariate variables
# including their interaction
##################################
DBP.Analysis.MultivariateCoxPH.PhEcogSexAge.WithInteraction.KaplanMeierEstimates <- survfit(DBP.Analysis.MultivariateCoxPH.PhEcogSexAge.WithInteraction, data = DBP.Analysis.Filtered)

SurvivalTimeInWeek.KaplanMeier.MultivariateCoxPH.PhEcogSexAge.WithInteraction <- ggsurvplot(DBP.Analysis.MultivariateCoxPH.PhEcogSexAge.WithInteraction.KaplanMeierEstimates,
                                                     title = "Kaplan-Meier Survival Curves (CoxPH Model : Survival ~ ECOG Score * Sex * Age)",
                                                     pval = FALSE,
                                                     conf.int = TRUE,
                                                     conf.int.style = "ribbon",
                                                     xlab = "Time (Days)",
                                                     ylab="Estimated Survival Probability",
                                                     break.time.by = 100,
                                                     ggtheme = theme_bw(),
                                                     risk.table = "abs_pct",
                                                     risk.table.title="Number at Risk (Survival Probability)",
                                                     risk.table.y.text.col = FALSE,
                                                     risk.table.y.text = TRUE,
                                                     fontsize = 3,
                                                     ncensor.plot = FALSE,
                                                     surv.median.line = "hv",
                                                     palette = c("#000000"))

ggpar(SurvivalTimeInWeek.KaplanMeier.MultivariateCoxPH.PhEcogSexAge.WithInteraction,
      font.title = c(14,"bold"),
      font.x = c(12,"bold"),
      font.y = c(12,"bold"),
      font.legend=c(12),
      font.xtickslab=c(9,"black"),
      font.ytickslab=c(9,"black"))

##################################
# Formulating a Multivariate Cox Proportional Hazards Model
# with both the Factor and Covariate Variables
##################################
(DBP.Analysis.MultivariateCoxPH.PhEcogSex <- coxph(Surv(time, status) ~ ph.ecog + sex , data = DBP.Analysis.Filtered))
## Call:
## coxph(formula = Surv(time, status) ~ ph.ecog + sex, data = DBP.Analysis.Filtered)
## 
##                        coef exp(coef) se(coef)      z        p
## ph.ecogAmbulatory   -0.5433    0.5808   0.1861 -2.919  0.00351
## ph.ecogAsymptomatic -0.9611    0.3825   0.2237 -4.297 1.73e-05
## sexFemale           -0.5503    0.5768   0.1679 -3.277  0.00105
## 
## Likelihood ratio test=28.66  on 3 df, p=2.643e-06
## n= 227, number of events= 164
summary(DBP.Analysis.MultivariateCoxPH.PhEcogSex)
## Call:
## coxph(formula = Surv(time, status) ~ ph.ecog + sex, data = DBP.Analysis.Filtered)
## 
##   n= 227, number of events= 164 
## 
##                        coef exp(coef) se(coef)      z Pr(>|z|)    
## ph.ecogAmbulatory   -0.5433    0.5808   0.1861 -2.919  0.00351 ** 
## ph.ecogAsymptomatic -0.9611    0.3825   0.2237 -4.297 1.73e-05 ***
## sexFemale           -0.5503    0.5768   0.1679 -3.277  0.00105 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
##                     exp(coef) exp(-coef) lower .95 upper .95
## ph.ecogAmbulatory      0.5808      1.722    0.4033    0.8365
## ph.ecogAsymptomatic    0.3825      2.615    0.2467    0.5929
## sexFemale              0.5768      1.734    0.4151    0.8016
## 
## Concordance= 0.642  (se = 0.025 )
## Likelihood ratio test= 28.66  on 3 df,   p=3e-06
## Wald test            = 28.99  on 3 df,   p=2e-06
## Score (logrank) test = 30.04  on 3 df,   p=1e-06
tbl_regression(DBP.Analysis.MultivariateCoxPH.PhEcogSex,
               exponentiate = TRUE)
Characteristic HR1 95% CI1 p-value
ph.ecog


    Bedridden
    Ambulatory 0.58 0.40, 0.84 0.004
    Asymptomatic 0.38 0.25, 0.59 <0.001
sex


    Male
    Female 0.58 0.42, 0.80 0.001
1 HR = Hazard Ratio, CI = Confidence Interval
(DBP.Analysis.MultivariateCoxPH.DBP.Analysis.MultivariateCoxPH.PhEcogSex.ForestPlot <- ggforest(DBP.Analysis.MultivariateCoxPH.PhEcogSex,
          data=DBP.Analysis.Filtered,
          main = "",
          fontsize = 0.9))

##################################
# Plotting the Kaplan-Meier survival curves
# for the formulated Multivariate Cox Proportional Hazards Model
# involving the Factor and Covariate variables
##################################
DBP.Analysis.MultivariateCoxPH.PhEcogSex.KaplanMeierEstimates <- survfit(DBP.Analysis.MultivariateCoxPH.PhEcogSex , data = DBP.Analysis.Filtered)

SurvivalTimeInWeek.KaplanMeier.MultivariateCoxPH.PhEcogSex <- ggsurvplot(DBP.Analysis.MultivariateCoxPH.PhEcogSex.KaplanMeierEstimates,
                                                     title = "Kaplan-Meier Survival Curves (CoxPH Model : Survival ~ ECOG Score + Sex)",
                                                     pval = FALSE,
                                                     conf.int = TRUE,
                                                     conf.int.style = "ribbon",
                                                     xlab = "Time (Days)",
                                                     ylab="Estimated Survival Probability",
                                                     break.time.by = 100,
                                                     ggtheme = theme_bw(),
                                                     risk.table = "abs_pct",
                                                     risk.table.title="Number at Risk (Survival Probability)",
                                                     risk.table.y.text.col = FALSE,
                                                     risk.table.y.text = TRUE,
                                                     fontsize = 3,
                                                     ncensor.plot = FALSE,
                                                     surv.median.line = "hv",
                                                     palette = c("#000000"))

ggpar(SurvivalTimeInWeek.KaplanMeier.MultivariateCoxPH.PhEcogSex,
      font.title = c(14,"bold"),
      font.x = c(12,"bold"),
      font.y = c(12,"bold"),
      font.legend=c(12),
      font.xtickslab=c(9,"black"),
      font.ytickslab=c(9,"black"))

##################################
# Formulating a Multivariate Cox Proportional Hazards Model
# with both the Factor and Covariate Variables
# including their interaction
##################################
(DBP.Analysis.MultivariateCoxPH.PhEcogSex.WithInteraction <- coxph(Surv(time, status) ~ ph.ecog + sex + ph.ecog*sex, data = DBP.Analysis.Filtered))
## Call:
## coxph(formula = Surv(time, status) ~ ph.ecog + sex + ph.ecog * 
##     sex, data = DBP.Analysis.Filtered)
## 
##                                  coef exp(coef) se(coef)      z       p
## ph.ecogAmbulatory             -0.4669    0.6269   0.2312 -2.020 0.04339
## ph.ecogAsymptomatic           -0.8692    0.4193   0.2667 -3.259 0.00112
## sexFemale                     -0.3724    0.6891   0.3130 -1.190 0.23419
## ph.ecogAmbulatory:sexFemale   -0.2258    0.7979   0.3927 -0.575 0.56533
## ph.ecogAsymptomatic:sexFemale -0.3055    0.7367   0.4945 -0.618 0.53670
## 
## Likelihood ratio test=29.13  on 5 df, p=2.186e-05
## n= 227, number of events= 164
summary(DBP.Analysis.MultivariateCoxPH.PhEcogSex.WithInteraction)
## Call:
## coxph(formula = Surv(time, status) ~ ph.ecog + sex + ph.ecog * 
##     sex, data = DBP.Analysis.Filtered)
## 
##   n= 227, number of events= 164 
## 
##                                  coef exp(coef) se(coef)      z Pr(>|z|)   
## ph.ecogAmbulatory             -0.4669    0.6269   0.2312 -2.020  0.04339 * 
## ph.ecogAsymptomatic           -0.8692    0.4193   0.2667 -3.259  0.00112 **
## sexFemale                     -0.3724    0.6891   0.3130 -1.190  0.23419   
## ph.ecogAmbulatory:sexFemale   -0.2258    0.7979   0.3927 -0.575  0.56533   
## ph.ecogAsymptomatic:sexFemale -0.3055    0.7367   0.4945 -0.618  0.53670   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
##                               exp(coef) exp(-coef) lower .95 upper .95
## ph.ecogAmbulatory                0.6269      1.595    0.3985    0.9862
## ph.ecogAsymptomatic              0.4193      2.385    0.2486    0.7072
## sexFemale                        0.6891      1.451    0.3731    1.2727
## ph.ecogAmbulatory:sexFemale      0.7979      1.253    0.3695    1.7228
## ph.ecogAsymptomatic:sexFemale    0.7367      1.357    0.2795    1.9420
## 
## Concordance= 0.643  (se = 0.025 )
## Likelihood ratio test= 29.13  on 5 df,   p=2e-05
## Wald test            = 28.01  on 5 df,   p=4e-05
## Score (logrank) test = 30.3  on 5 df,   p=1e-05
tbl_regression(DBP.Analysis.MultivariateCoxPH.PhEcogSex.WithInteraction,
               exponentiate = TRUE)
Characteristic HR1 95% CI1 p-value
ph.ecog


    Bedridden
    Ambulatory 0.63 0.40, 0.99 0.043
    Asymptomatic 0.42 0.25, 0.71 0.001
sex


    Male
    Female 0.69 0.37, 1.27 0.2
ph.ecog * sex


    Ambulatory * Female 0.80 0.37, 1.72 0.6
    Asymptomatic * Female 0.74 0.28, 1.94 0.5
1 HR = Hazard Ratio, CI = Confidence Interval
(DBP.Analysis.MultivariateCoxPH.PhEcogSex.WithInteraction.ForestPlot <- ggforest(DBP.Analysis.MultivariateCoxPH.PhEcogSex.WithInteraction,
          data=DBP.Analysis.Filtered,
          main = "",
          fontsize = 0.9))

##################################
# Plotting the Kaplan-Meier survival curves
# for the formulated Multivariate Cox Proportional Hazards Model
# involving the Factor and Covariate variables
# including their interaction
##################################
DBP.Analysis.MultivariateCoxPH.PhEcogSex.WithInteraction.KaplanMeierEstimates <- survfit(DBP.Analysis.MultivariateCoxPH.PhEcogSex.WithInteraction, data = DBP.Analysis.Filtered)

SurvivalTimeInWeek.KaplanMeier.MultivariateCoxPH.PhEcogSex.WithInteraction <- ggsurvplot(DBP.Analysis.MultivariateCoxPH.PhEcogSex.WithInteraction.KaplanMeierEstimates,
                                                     title = "Kaplan-Meier Survival Curves (CoxPH Model : Survival ~ ECOG Score * Sex)",
                                                     pval = FALSE,
                                                     conf.int = TRUE,
                                                     conf.int.style = "ribbon",
                                                     xlab = "Time (Days)",
                                                     ylab="Estimated Survival Probability",
                                                     break.time.by = 100,
                                                     ggtheme = theme_bw(),
                                                     risk.table = "abs_pct",
                                                     risk.table.title="Number at Risk (Survival Probability)",
                                                     risk.table.y.text.col = FALSE,
                                                     risk.table.y.text = TRUE,
                                                     fontsize = 3,
                                                     ncensor.plot = FALSE,
                                                     surv.median.line = "hv",
                                                     palette = c("#000000"))

ggpar(SurvivalTimeInWeek.KaplanMeier.MultivariateCoxPH.PhEcogSex.WithInteraction,
      font.title = c(14,"bold"),
      font.x = c(12,"bold"),
      font.y = c(12,"bold"),
      font.legend=c(12),
      font.xtickslab=c(9,"black"),
      font.ytickslab=c(9,"black"))

##################################
# Formulating complete and reduced
# Multivariate Cox Proportional Hazards Models
# involving the Factor and Covariate Variables
##################################
DBP.Analysis.SurvivalResponse <- "Surv(time, status)"
DBP.Analysis.SurvivalPredictorComplete <- c("ph.ecog", "sex", "age")
DBP.Analysis.SurvivalPredictorReduced <- c("ph.ecog", "sex")

DBP.Analysis.CoxPHModelSummary <- DBP.Analysis.Filtered %>%
  finalfit(DBP.Analysis.SurvivalResponse,
           DBP.Analysis.SurvivalPredictorComplete,
           DBP.Analysis.SurvivalPredictorReduced,
           keep_models = TRUE,
           add_dependent_label = FALSE) %>%
  rename("Overall Survival" = label) %>%
  rename(" " = levels) %>%
  rename("  " = all)

kable(DBP.Analysis.CoxPHModelSummary)
Overall Survival HR (univariable) HR (multivariable full) HR (multivariable)
4 ph.ecog Bedridden 51 (22.5) - - -
2 Ambulatory 113 (49.8) 0.57 (0.40-0.82, p=0.003) 0.60 (0.42-0.87, p=0.007) 0.58 (0.40-0.84, p=0.004)
3 Asymptomatic 63 (27.8) 0.39 (0.25-0.61, p<0.001) 0.40 (0.26-0.62, p<0.001) 0.38 (0.25-0.59, p<0.001)
6 sex Male 137 (60.4) - - -
5 Female 90 (39.6) 0.59 (0.43-0.82, p=0.002) 0.58 (0.41-0.80, p=0.001) 0.58 (0.42-0.80, p=0.001)
1 age Mean (SD) 62.5 (9.1) 1.02 (1.00-1.04, p=0.040) 1.01 (0.99-1.03, p=0.235) -

1.5.3 Model Selection


Code Chunk | Output
##################################
# Applying Stepwise Variable Selection
##################################
DBP.Analysis.MultivariateCoxPH.StepwiseSelection <- stepAIC(DBP.Analysis.MultivariateCoxPH.PhEcogSexAge, 
                      direction = "both", 
                      trace = TRUE)
## Start:  AIC=1466.88
## Surv(time, status) ~ ph.ecog + sex + age
## 
##           Df    AIC
## - age      1 1466.3
## <none>       1466.9
## - sex      1 1476.2
## - ph.ecog  2 1479.1
## 
## Step:  AIC=1466.3
## Surv(time, status) ~ ph.ecog + sex
## 
##           Df    AIC
## <none>       1466.3
## + age      1 1466.9
## - sex      1 1475.6
## - ph.ecog  2 1480.7
summary(DBP.Analysis.MultivariateCoxPH.StepwiseSelection)
## Call:
## coxph(formula = Surv(time, status) ~ ph.ecog + sex, data = DBP.Analysis.Filtered)
## 
##   n= 227, number of events= 164 
## 
##                        coef exp(coef) se(coef)      z Pr(>|z|)    
## ph.ecogAmbulatory   -0.5433    0.5808   0.1861 -2.919  0.00351 ** 
## ph.ecogAsymptomatic -0.9611    0.3825   0.2237 -4.297 1.73e-05 ***
## sexFemale           -0.5503    0.5768   0.1679 -3.277  0.00105 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
##                     exp(coef) exp(-coef) lower .95 upper .95
## ph.ecogAmbulatory      0.5808      1.722    0.4033    0.8365
## ph.ecogAsymptomatic    0.3825      2.615    0.2467    0.5929
## sexFemale              0.5768      1.734    0.4151    0.8016
## 
## Concordance= 0.642  (se = 0.025 )
## Likelihood ratio test= 28.66  on 3 df,   p=3e-06
## Wald test            = 28.99  on 3 df,   p=2e-06
## Score (logrank) test = 30.04  on 3 df,   p=1e-06
##################################
# Reusing formulated models
##################################
summary(DBP.Analysis.UnivariateCoxPH.PhEcog)
## Call:
## coxph(formula = Surv(time, status) ~ ph.ecog, data = DBP.Analysis.Filtered)
## 
##   n= 227, number of events= 164 
## 
##                        coef exp(coef) se(coef)      z Pr(>|z|)    
## ph.ecogAmbulatory   -0.5628    0.5696   0.1863 -3.021  0.00252 ** 
## ph.ecogAsymptomatic -0.9309    0.3942   0.2235 -4.166 3.11e-05 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
##                     exp(coef) exp(-coef) lower .95 upper .95
## ph.ecogAmbulatory      0.5696      1.755    0.3954    0.8207
## ph.ecogAsymptomatic    0.3942      2.537    0.2544    0.6108
## 
## Concordance= 0.604  (se = 0.024 )
## Likelihood ratio test= 17.33  on 2 df,   p=2e-04
## Wald test            = 18.17  on 2 df,   p=1e-04
## Score (logrank) test = 19  on 2 df,   p=7e-05
summary(DBP.Analysis.MultivariateCoxPH.PhEcogSex)
## Call:
## coxph(formula = Surv(time, status) ~ ph.ecog + sex, data = DBP.Analysis.Filtered)
## 
##   n= 227, number of events= 164 
## 
##                        coef exp(coef) se(coef)      z Pr(>|z|)    
## ph.ecogAmbulatory   -0.5433    0.5808   0.1861 -2.919  0.00351 ** 
## ph.ecogAsymptomatic -0.9611    0.3825   0.2237 -4.297 1.73e-05 ***
## sexFemale           -0.5503    0.5768   0.1679 -3.277  0.00105 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
##                     exp(coef) exp(-coef) lower .95 upper .95
## ph.ecogAmbulatory      0.5808      1.722    0.4033    0.8365
## ph.ecogAsymptomatic    0.3825      2.615    0.2467    0.5929
## sexFemale              0.5768      1.734    0.4151    0.8016
## 
## Concordance= 0.642  (se = 0.025 )
## Likelihood ratio test= 28.66  on 3 df,   p=3e-06
## Wald test            = 28.99  on 3 df,   p=2e-06
## Score (logrank) test = 30.04  on 3 df,   p=1e-06
summary(DBP.Analysis.MultivariateCoxPH.PhEcogSex.WithInteraction)
## Call:
## coxph(formula = Surv(time, status) ~ ph.ecog + sex + ph.ecog * 
##     sex, data = DBP.Analysis.Filtered)
## 
##   n= 227, number of events= 164 
## 
##                                  coef exp(coef) se(coef)      z Pr(>|z|)   
## ph.ecogAmbulatory             -0.4669    0.6269   0.2312 -2.020  0.04339 * 
## ph.ecogAsymptomatic           -0.8692    0.4193   0.2667 -3.259  0.00112 **
## sexFemale                     -0.3724    0.6891   0.3130 -1.190  0.23419   
## ph.ecogAmbulatory:sexFemale   -0.2258    0.7979   0.3927 -0.575  0.56533   
## ph.ecogAsymptomatic:sexFemale -0.3055    0.7367   0.4945 -0.618  0.53670   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
##                               exp(coef) exp(-coef) lower .95 upper .95
## ph.ecogAmbulatory                0.6269      1.595    0.3985    0.9862
## ph.ecogAsymptomatic              0.4193      2.385    0.2486    0.7072
## sexFemale                        0.6891      1.451    0.3731    1.2727
## ph.ecogAmbulatory:sexFemale      0.7979      1.253    0.3695    1.7228
## ph.ecogAsymptomatic:sexFemale    0.7367      1.357    0.2795    1.9420
## 
## Concordance= 0.643  (se = 0.025 )
## Likelihood ratio test= 29.13  on 5 df,   p=2e-05
## Wald test            = 28.01  on 5 df,   p=4e-05
## Score (logrank) test = 30.3  on 5 df,   p=1e-05
##################################
# Formulating the linear predictors
# for the formulated Univariate Cox Proportional Hazards Models
##################################
DBP.Analysis.Filtered$LP.Univariate.PhEcog <- predict(DBP.Analysis.UnivariateCoxPH.PhEcog, type = "lp")

##################################
# Formulating the linear predictors
# for the formulated Multivariate Cox Proportional Hazards Models
##################################
DBP.Analysis.Filtered$LP.Multivariate.PhEcogSex <- predict(DBP.Analysis.MultivariateCoxPH.PhEcogSex, type = "lp")
DBP.Analysis.Filtered$LP.Multivariate.PhEcogSex.WithInteraction <- predict(DBP.Analysis.MultivariateCoxPH.PhEcogSex.WithInteraction, type = "lp")

##################################
# Conducting a likelihood ratio test between nested models
# including the formulated Multivariate Cox Proportional Hazards Models
# involving the Factor variable only
# and both Factor and Covariate variables
##################################
(LikelihoodRatioTest.CoxPHPhEcog.CoxPHPhEcogSex <- anova(DBP.Analysis.UnivariateCoxPH.PhEcog,
      DBP.Analysis.MultivariateCoxPH.PhEcogSex,
      test="LRT"))
## Analysis of Deviance Table
##  Cox model: response is  Surv(time, status)
##  Model 1: ~ ph.ecog
##  Model 2: ~ ph.ecog + sex
##    loglik  Chisq Df Pr(>|Chi|)    
## 1 -735.81                         
## 2 -730.15 11.324  1  0.0007652 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##################################
# Conducting a likelihood ratio test between nested models
# including the formulated Multivariate Cox Proportional Hazards Models
# involving both Factor and Covariate variables only
# and both Factor and Covariate variables including their interaction
##################################
(LikelihoodRatioTest.CoxPHPhEcogSex.CoxPHPhEcogSexWithInteraction <- anova(DBP.Analysis.MultivariateCoxPH.PhEcogSex,
      DBP.Analysis.MultivariateCoxPH.PhEcogSex.WithInteraction,
      test="LRT"))
## Analysis of Deviance Table
##  Cox model: response is  Surv(time, status)
##  Model 1: ~ ph.ecog + sex
##  Model 2: ~ ph.ecog + sex + ph.ecog * sex
##    loglik  Chisq Df Pr(>|Chi|)
## 1 -730.15                     
## 2 -729.92 0.4727  2     0.7895

1.5.4 Model Performance Validation


Code Chunk | Output
##################################
# Measuring the Harrel's Concordance Index
# for the formulated Univariate Cox Proportional Hazards Model
# involving the Factor variable
##################################
rcorrcens(formula = Surv(time, status) ~ I(-1 * LP.Univariate.PhEcog), data = DBP.Analysis.Filtered)
## 
## Somers' Rank Correlation for Censored Data    Response variable:Surv(time, status)
## 
##                                  C   Dxy  aDxy    SD    Z P   n
## I(-1 * LP.Univariate.PhEcog) 0.604 0.208 0.208 0.048 4.35 0 227
LP.Univariate.PhEcog.Concordance <- survConcordance(Surv(time, status) ~ LP.Univariate.PhEcog,
                                               data = DBP.Analysis.Filtered)

(LP.Univariate.PhEcog.Concordance$concordance)
## concordant 
##  0.6039571
DBP.Analysis.UnivariateCoxPH.PhEcog.Validation <- cph(Surv(time, status) ~ ph.ecog,
                                                     x=TRUE,
                                                     y=TRUE,
                                                     data = DBP.Analysis.Filtered)

set.seed (88888888)
DBP.Analysis.UnivariateCoxPH.PhEcog.Validation.Summary <- validate(DBP.Analysis.UnivariateCoxPH.PhEcog.Validation, B =500)

(DBP.Analysis.UnivariateCoxPH.PhEcog.ConcordanceIndex.Optimistic <- (DBP.Analysis.UnivariateCoxPH.PhEcog.Validation.Summary[1,1]/2)+0.50)
## [1] 0.6039571
(DBP.Analysis.UnivariateCoxPH.PhEcog.ConcordanceIndex.OptimismCorrected <- (DBP.Analysis.UnivariateCoxPH.PhEcog.Validation.Summary[1,5]/2)+0.50)
## [1] 0.6035354
##################################
# Measuring the Harrel's Concordance Index
# for the formulated Multivariate Cox Proportional Hazards Model
# involving the Factor and Covariate variables
##################################
rcorrcens(formula = Surv(time, status) ~ I(-1 * LP.Multivariate.PhEcogSex), data = DBP.Analysis.Filtered)
## 
## Somers' Rank Correlation for Censored Data    Response variable:Surv(time, status)
## 
##                                       C   Dxy  aDxy    SD    Z P   n
## I(-1 * LP.Multivariate.PhEcogSex) 0.642 0.284 0.284 0.049 5.74 0 227
LP.Multivariate.PhEcogSex.Concordance <- survConcordance(Surv(time, status) ~ LP.Multivariate.PhEcogSex,
                                                        data = DBP.Analysis.Filtered)

(LP.Multivariate.PhEcogSex.Concordance$concordance)
## concordant 
##  0.6418861
DBP.Analysis.Multivariate.PhEcogSex.Validation <- cph(Surv(time, status) ~ ph.ecog + sex,
                                                     x=TRUE,
                                                     y=TRUE,
                                                     data = DBP.Analysis.Filtered)

set.seed (88888888)
DBP.Analysis.Multivariate.PhEcogSex.Validation.Summary <- validate(DBP.Analysis.Multivariate.PhEcogSex.Validation, B =500)

(DBP.Analysis.Multivariate.PhEcogSex.ConcordanceIndex.Optimistic <- (DBP.Analysis.Multivariate.PhEcogSex.Validation.Summary[1,1]/2)+0.50)
## [1] 0.6418861
(DBP.Analysis.Multivariate.PhEcogSex.ConcordanceIndex.OptimismCorrected <- (DBP.Analysis.Multivariate.PhEcogSex.Validation.Summary[1,5]/2)+0.50)
## [1] 0.6355095
##################################
# Measuring the Harrel's Concordance Index
# for the formulated Multivariate Cox Proportional Hazards Model
# involving the Factor and Covariate variables
# including their interaction
##################################
rcorrcens(formula = Surv(time, status) ~ I(-1 * LP.Multivariate.PhEcogSex.WithInteraction), data = DBP.Analysis.Filtered)
## 
## Somers' Rank Correlation for Censored Data    Response variable:Surv(time, status)
## 
##                                                       C   Dxy  aDxy    SD    Z
## I(-1 * LP.Multivariate.PhEcogSex.WithInteraction) 0.643 0.286 0.286 0.049 5.83
##                                                   P   n
## I(-1 * LP.Multivariate.PhEcogSex.WithInteraction) 0 227
LP.Multivariate.PhEcogSex.WithInteraction.Concordance <- survConcordance(Surv(time, status) ~ LP.Multivariate.PhEcogSex.WithInteraction, data = DBP.Analysis.Filtered)

(LP.Multivariate.PhEcogSex.WithInteraction.Concordance$concordance)
## concordant 
##  0.6432001
DBP.Analysis.Multivariate.PhEcogSex.WithInteraction.Validation <- cph(Surv(time, status) ~ ph.ecog + sex + ph.ecog*sex,
                                                     x=TRUE,
                                                     y=TRUE,
                                                     data = DBP.Analysis.Filtered)

set.seed (88888888)
DBP.Analysis.Multivariate.PhEcogSex.WithInteraction.Validation.Summary <- validate(DBP.Analysis.Multivariate.PhEcogSex.WithInteraction.Validation, B =500)

(DBP.Analysis.Multivariate.PhEcogSex.WithInteraction.ConcordanceIndex.Optimistic <- (DBP.Analysis.Multivariate.PhEcogSex.WithInteraction.Validation.Summary[1,1]/2)+0.50)
## [1] 0.6432001
(DBP.Analysis.Multivariate.PhEcogSex.WithInteraction.ConcordanceIndex.OptimismCorrected <- (DBP.Analysis.Multivariate.PhEcogSex.WithInteraction.Validation.Summary[1,5]/2)+0.50)
## [1] 0.632923

1.5.5 Model Diagnostics


Code Chunk | Output
##################################
# Reusing selected model
##################################
summary(DBP.Analysis.MultivariateCoxPH.PhEcogSex)
## Call:
## coxph(formula = Surv(time, status) ~ ph.ecog + sex, data = DBP.Analysis.Filtered)
## 
##   n= 227, number of events= 164 
## 
##                        coef exp(coef) se(coef)      z Pr(>|z|)    
## ph.ecogAmbulatory   -0.5433    0.5808   0.1861 -2.919  0.00351 ** 
## ph.ecogAsymptomatic -0.9611    0.3825   0.2237 -4.297 1.73e-05 ***
## sexFemale           -0.5503    0.5768   0.1679 -3.277  0.00105 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
##                     exp(coef) exp(-coef) lower .95 upper .95
## ph.ecogAmbulatory      0.5808      1.722    0.4033    0.8365
## ph.ecogAsymptomatic    0.3825      2.615    0.2467    0.5929
## sexFemale              0.5768      1.734    0.4151    0.8016
## 
## Concordance= 0.642  (se = 0.025 )
## Likelihood ratio test= 28.66  on 3 df,   p=3e-06
## Wald test            = 28.99  on 3 df,   p=2e-06
## Score (logrank) test = 30.04  on 3 df,   p=1e-06
tbl_regression(DBP.Analysis.MultivariateCoxPH.PhEcogSex,
               exponentiate = TRUE)
Characteristic HR1 95% CI1 p-value
ph.ecog


    Bedridden
    Ambulatory 0.58 0.40, 0.84 0.004
    Asymptomatic 0.38 0.25, 0.59 <0.001
sex


    Male
    Female 0.58 0.42, 0.80 0.001
1 HR = Hazard Ratio, CI = Confidence Interval
(DBP.Analysis.MultivariateCoxPH.DBP.Analysis.MultivariateCoxPH.PhEcogSex.ForestPlot <- ggforest(DBP.Analysis.MultivariateCoxPH.PhEcogSex,
          data=DBP.Analysis.Filtered,
          main = "",
          fontsize = 0.9))

##################################
# Plotting the Kaplan-Meier survival curves
# for the formulated Multivariate Cox Proportional Hazards Model
# involving the Factor and Covariate variables
##################################
DBP.Analysis.MultivariateCoxPH.PhEcogSex.KaplanMeierEstimates <- survfit(DBP.Analysis.MultivariateCoxPH.PhEcogSex , data = DBP.Analysis.Filtered)

SurvivalTimeInWeek.KaplanMeier.MultivariateCoxPH.PhEcogSex <- ggsurvplot(DBP.Analysis.MultivariateCoxPH.PhEcogSex.KaplanMeierEstimates,
                                                     title = "Kaplan-Meier Survival Curves (CoxPH Model : Survival ~ ECOG Score + Sex)",
                                                     pval = FALSE,
                                                     conf.int = TRUE,
                                                     conf.int.style = "ribbon",
                                                     xlab = "Time (Days)",
                                                     ylab="Estimated Survival Probability",
                                                     break.time.by = 100,
                                                     ggtheme = theme_bw(),
                                                     risk.table = "abs_pct",
                                                     risk.table.title="Number at Risk (Survival Probability)",
                                                     risk.table.y.text.col = FALSE,
                                                     risk.table.y.text = TRUE,
                                                     fontsize = 3,
                                                     ncensor.plot = FALSE,
                                                     surv.median.line = "hv",
                                                     palette = c("#000000"))

ggpar(SurvivalTimeInWeek.KaplanMeier.MultivariateCoxPH.PhEcogSex,
      font.title = c(14,"bold"),
      font.x = c(12,"bold"),
      font.y = c(12,"bold"),
      font.legend=c(12),
      font.xtickslab=c(9,"black"),
      font.ytickslab=c(9,"black"))

##################################
# Plotting the Kaplan-Meier survival curves
# of the Factor variable adjusted by the Covariate variable 
# using the formulated Multivariate Cox Proportional Hazards Model
##################################

(DBP.PhEcogAdjustedBySex <- with(DBP.Analysis.Filtered,
                                 data.frame(ph.ecog = c("Bedridden", "Ambulatory","Asymptomatic"),
                                            sex = c("Male", "Male", "Male"))))
##        ph.ecog  sex
## 1    Bedridden Male
## 2   Ambulatory Male
## 3 Asymptomatic Male
DBP.Analysis.MultivariateCoxPH.PhEcogSex.PhEcogAdjustedBySex.KaplanMeierEstimates <- survfit(DBP.Analysis.MultivariateCoxPH.PhEcogSex, 
                                                                                             newdata = DBP.PhEcogAdjustedBySex, 
                                                                                             data=DBP.Analysis.Filtered)


SurvivalTimeInWeek.KaplanMeier.MultivariateCoxPH.PhEcogSex.PhEcogAdjustedBySex <- ggsurvplot(DBP.Analysis.MultivariateCoxPH.PhEcogSex.PhEcogAdjustedBySex.KaplanMeierEstimates,
                                                                         title = "Kaplan-Meier Survival Curves (CoxPH Model : Survival ~ ECOG Score + Sex)",
                                                                         pval = TRUE,
                                                                         conf.int = TRUE,
                                                                         conf.int.style = "ribbon",
                                                                         xlab = "Time (Days)",
                                                                         ylab="Estimated Survival Probability",
                                                                         break.time.by = 100,
                                                                         ggtheme = theme_bw(),
                                                                         risk.table = "abs_pct",
                                                                         risk.table.title="Number at Risk (Survival Probability)",
                                                                         risk.table.y.text.col = FALSE,
                                                                         risk.table.y.text = TRUE,
                                                                         fontsize = 3,
                                                                         ncensor.plot = FALSE,
                                                                         surv.median.line = "hv",
                                                                         legend.labs = c("Bedridden", "Ambulatory", "Asymptomatic"),
                                                                         palette = c("#00CC66","#3259A0","#FF5050"))

ggpar(SurvivalTimeInWeek.KaplanMeier.MultivariateCoxPH.PhEcogSex.PhEcogAdjustedBySex,
      font.title = c(14,"bold"),
      font.x = c(12,"bold"),
      font.y = c(12,"bold"),
      font.legend=c(12),
      font.xtickslab=c(9,"black"),
      font.ytickslab=c(9,"black"))

##################################
# Testing the proportional hazards assumption
# based on the scaled Schoenfield residuals
##################################
(DBP.Analysis.MultivariateCoxPH.PhEcogSex.PHAssumptionCheck <- cox.zph(DBP.Analysis.MultivariateCoxPH.PhEcogSex))
##         chisq df    p
## ph.ecog  3.04  2 0.22
## sex      2.70  1 0.10
## GLOBAL   5.29  3 0.15
##################################
# Formulating the graphical verification
# of the proportional hazards assumption test results
# using the scaled Schoenfeld residuals against time
##################################
(DBP.Analysis.MultivariateCoxPH.PhEcogSex.PHAssumptionPlot <- ggcoxzph(DBP.Analysis.MultivariateCoxPH.PhEcogSex.PHAssumptionCheck,
         point.col = "red",
         point.size = 2,
         point.shape = 19,
         point.alpha = 0.50,
  ggtheme = theme_survminer(),
  font.main = c(12,"bold"),
  font.x = c(12,"bold"),
  font.y = c(12,"bold"),
  font.xtickslab=c(9,"black"),
  font.ytickslab=c(9,"black")))

##################################
# Formulating the graphical verification
# to evaluate potential influential observations
# using the deviance residuals against observations
##################################
ggcoxdiagnostics(DBP.Analysis.MultivariateCoxPH.PhEcogSex,
 type = "deviance",
 ox.scale = "observation.id",
 point.col = "red",
 point.size = 2,
 point.shape = 19,
 point.alpha = 0.50,
 ggtheme = theme_survminer(),
 font.main = c(12,"bold"),
 font.x = c(12,"bold"),
 font.y = c(12,"bold"),
 font.xtickslab=c(9,"black"),
 font.ytickslab=c(9,"black"),
 main = "Deviance Residuals by Observation")

##################################
# Formulating the graphical verification
# to evaluate symmetry
# using the dfbeta residuals against observations
##################################
ggcoxdiagnostics(DBP.Analysis.MultivariateCoxPH.PhEcogSex,
 type = "dfbeta",
 ox.scale = "observation.id",
 point.col = "red",
 point.size = 2,
 point.shape = 19,
 point.alpha = 0.50,
 ggtheme = theme_survminer(),
 font.main = c(12,"bold"),
 font.x = c(12,"bold"),
 font.y = c(12,"bold"),
 font.xtickslab=c(9,"black"),
 font.ytickslab=c(9,"black"),
 main = "Deviance Residuals by Observation")

##################################
# Formulating the graphical verification
# to evaluate linearity of the numeric covariate
# using the martingale residuals of the null cox proportional hazards model
# and the individual values of the numeric covariate
##################################
# No graphical verification proceeded
# due to the absence of a numeric covariate
# on the final selected model

2. Summary



3. References


[Book] Survival Analysis : A Self-Learning Text by David Kleinbaum and Mitchel Klein
[Book] Applied Survival Analysis Using R by Dirk Moore
[Book] R for Health Data Science by Ewen Harrison and Riinu Pius
[Book] Supervised Machine Learning by Michael Foley
[Book] Data Science for Biological, Medical and Health Research by Thomas Love
[R Package] moments by Lukasz Komsta and Frederick Novomestky
[R Package] car by John Fox and Sanford Weisberg
[R Package] multcomp by Torsten Hothorn, Frank Bretz and Peter Westfall
[R Package] effects by John Fox and Sanford Weisberg
[R Package] psych by William Revelle
[R Package] ggplot2 by Hadley Wickham
[R Package] dplyr by Hadley Wickham
[R Package] ggpubr by Alboukadel Kassambara
[R Package] rstatix by Alboukadel Kassambara
[R Package] ggfortify by Yuan Tang
[R Package] trend by Thorsten Pohlert
[R Package] survival by Terry Therneau
[R Package] rms by Frank Harrell
[R Package] survminer by Alboukadel Kassambara
[R Package] Hmisc by Frank Harrel
[R Package] finalfit by Ewen Harrison
[R Package] knitr by Yihui Xie
[R Package] gtsummary by Daniel Sjoberg
[Article] Survival Analysis by Alboukadel Kassambara
[Article] Survival Analysis in R by Emily Zabor
[Article] Survival Analysis with R by Joseph Rickert
[Article] Assessment of Discrimination in Survival Analysis by R-Studio Team
[Article] Cox Model Assumptions by Alboukadel Kassambara
[Publication] Regression Models and Life-Tables by David Cox (Royal Statistical Society)
[Publication] Evaluating the Yield of Medical Tests by Frank Harrell, Robert Califf, David Pryor, Kerry Lee and Robert Rosati (Journal of the American Medical Association)
[Publication] Survival Analysis Part I: Basic Concepts and First Analyses by Taane Clark (British Journal of Cancer)
[Publication] Survival Analysis Part II: Multivariate Data Analysis – An Introduction to Concepts and Methods by Mike Bradburn (British Journal of Cancer)
[Publication] Survival Analysis Part III: Multivariate Data Analysis – Choosing a Model and Assessing its Adequacy and Fit by Mike Bradburn (British Journal of Cancer)
[Publication] Survival Analysis Part IV: Further Concepts and Methods in Survival Analysis by Taane Clark (British Journal of Cancer)
[Tutorial] Survival Analysis / Time-To-Event Analysis in R by Heidi Seibold (Datacamp)