Error with Cox modelling survival curve

PMEC <- read_csv("New_Whole1150Data.csv")

# Filter out missing values in the outcome and other key variables

PMEC100 <- PMEC[complete.cases(PMEC$SURGERY_YESNO_BASEDON_REASON,

PMEC$AGE, PMEC$SEX, PMEC$RACE_MOD,

PMEC$SPANISH_HISPANIC_ORIGIN_MOD, PMEC$INCOME_ABOVE_MEDIAN1,

PMEC$FACILITY_TYPE_CD, PMEC$PRIMARY_SITE_mod_5,

PMEC$CDCC_TOTAL_BEST, PMEC$GRADE_mod,

PMEC$Combined_Clin_T_ForRegres, PMEC$CombinedClinN_POSORNEG,

PMEC$Combined_Clin_M, PMEC$CHEMO_YESNO, PMEC$RAD_YESNO_BASEDONREASON,

PMEC$PUF_VITAL_STATUS), ]

PMEC100$SURGERY_YESNO_BASEDON_REASON <- as.factor(PMEC100$SURGERY_YESNO_BASEDON_REASON)

PMEC100$SEX <- as.factor(PMEC100$SEX)

PMEC100$RACE_MOD <- as.factor(PMEC100$RACE_MOD)

PMEC100$SPANISH_HISPANIC_ORIGIN_MOD <- as.factor(PMEC100$SPANISH_HISPANIC_ORIGIN_MOD)

PMEC100$INCOME_ABOVE_MEDIAN1 <- as.factor(PMEC100$INCOME_ABOVE_MEDIAN1)

PMEC100$FACILITY_TYPE_CD <- as.factor(PMEC100$FACILITY_TYPE_CD)

PMEC100$PRIMARY_SITE_mod_5 <- as.factor(PMEC100$PRIMARY_SITE_mod_5)

PMEC100$CDCC_TOTAL_BEST <- as.factor(PMEC100$CDCC_TOTAL_BEST)

PMEC100$GRADE_mod <- as.factor(PMEC100$GRADE_mod)

PMEC100$Combined_Clin_T_ForRegres <- as.factor(PMEC100$Combined_Clin_T_ForRegres)

PMEC100$CombinedClinN_POSORNEG <- as.factor(PMEC100$CombinedClinN_POSORNEG)

PMEC100$Combined_Clin_M <- as.factor(PMEC100$Combined_Clin_M)

PMEC100$CHEMO_YESNO <- as.factor(PMEC100$CHEMO_YESNO)

PMEC100$RAD_YESNO_BASEDONREASON <- as.factor(PMEC100$RAD_YESNO_BASEDONREASON)

# Create a "Surv" object for the entire cohort

surv_data_cohort100 <- with(PMEC100, Surv(DX_LASTCONTACT_DEATH_MONTHS, PUF_VITAL_STATUS == 0))

# Create a data frame with variables for adjustment

adjustment_vars <- PMEC100[, c("AGE", "SEX", "RACE_MOD", "SPANISH_HISPANIC_ORIGIN_MOD",

"INCOME_ABOVE_MEDIAN1", "FACILITY_TYPE_CD", "PRIMARY_SITE_mod_5",

"CDCC_TOTAL_BEST", "GRADE_mod", "Combined_Clin_T_ForRegres",

"CombinedClinN_POSORNEG", "Combined_Clin_M", "CHEMO_YESNO",

"RAD_YESNO_BASEDONREASON")]

# Create a "Surv" object for the entire cohort

surv_data_cohort100 <- with(PMEC100, Surv(DX_LASTCONTACT_DEATH_MONTHS, PUF_VITAL_STATUS == 0))

# Fit the Cox proportional hazards model with adjustment for variables

cox_model <- coxph(surv_data_cohort100 ~ SURGERY_YESNO_BASEDON_REASON + AGE + SEX + RACE_MOD +

SPANISH_HISPANIC_ORIGIN_MOD + INCOME_ABOVE_MEDIAN1 + FACILITY_TYPE_CD +

PRIMARY_SITE_mod_5 + CDCC_TOTAL_BEST + GRADE_mod + Combined_Clin_T_ForRegres +

CombinedClinN_POSORNEG + Combined_Clin_M + CHEMO_YESNO + RAD_YESNO_BASEDONREASON,

data = PMEC100)

# Extract adjusted survival curves

surv_fit_adjusted <- survfit(cox_model)

# Plot the Kaplan-Meier survival curves for both subgroups

ggsurvplot(surv_fit_adjusted,

data = PMEC100, # Use the new data frame

risk.table = TRUE,

risk.table.title = "Survival Risk Table",

title = "Adjusted Kaplan-Meier Survival Curve",

xlab = "Time (months)",

ylab = "Overall Survival Probability",

pval = TRUE,

break.time.by = 24, # Break time axis by 2 years

palette = c("blue", "red"), # Set colors for subgroups

risk.table.col = "strata",

strata = PMEC100$SURGERY_YESNO_BASEDON_REASON,

tables.theme = theme_cleantable(),

conf.int = TRUE)

Can somebody tell me why this is throwing this specific error? Warning message: In .pvalue(fit, data = data, method = method, pval = pval, pval.coord = pval.coord, : There are no survival curves to be compared. This is a null model.

The intention is to create Survival curves of a Cox model, stratified by this factor variable - "SURGERY_YESNO_BASEDON_REASON" which is a Yes/No variable.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.