how to plot survival plots for piecewise cox model with variables that are stratified?

27 Views Asked by At

I was fitting the model as follows:

mutli_cox_strat_fin<-coxph(Surv(time, died) ~ ppi+gender+times+imd_person+strata(calendarperiod)+eth5+gastric_cancer+ulcer+gerd+bmi+age+I(age**2)+I(age**3)+as.factor(period), data = analysis_data_time_strat)

where period is from


analysis_data_time_strat <- survSplit(Surv(survival_time, died) ~ ., analysis_data_time, cut = c(seq(0,20,by=0.5)), start = "tstart", end = "time", episode = "period")

ie the splitting by that of every half year. I need to demonstrate the survival curve of that of person with certain characteristics. (a 50year old white man with no comorbdiities in the most deprived group.) note: verbatim instructions: (iv) Provide estimated survivor curves under the two exposure statuses based on your final multivariable model, for the following types of individual: a. A man aged 50 in the “White” ethnicity group, with no co-morbidities and in the most deprived group. (repeat for other demographics)

I tried to input what i want into a dataframe:

new_individual_a <- data.frame(
  ppi =as.factor(1),
  gender =as.factor("Male"),
  imd_person = as.factor("Least Deprived (1)"),
  calendarperiod = as.factor("1997-1999"),  
  eth5 = as.factor("White"),
  gastric_cancer = as.factor(0),
  ulcer = as.factor(0),
  gerd = as.factor(0),
  bmi = 25,  
  age = 50, 
  times=1)

I tried the follow methods:

ggadjustedcurves(mutli_cox_strat_fin, data = new_individual_a)

The variable argument is missing. Using calendarperiod as extracted from strata Error in data.frame(time = rep(c(0, pred$time), length(lev)), variable = factor(rep(lev, : arguments imply differing number of rows: 944, 1886 hence i though it was possible wrong stratification, since it was 2 times, i added "variable = "ppi"" to no avail

ggsurvplot(mutli_cox_strat_fin, data = new_individual_a)

this returns: Error in ggsurvplot(mutli_cox_strat_fin, data = new_individual_a) : object 'ggsurv' not found

i though it was because of the libraries (library(survival),library(survminer)),so i loaded and reinstalled them, but to no avail.

i couldnt find other methods, so i tired to extract the survivor function and plot it directedly

predicted_survival <- predict(mutli_cox_strat_fin, newdata = new_individual_a, type = "expected")

returns zero. tried all options (“lp”, “risk”, “expected”, “terms”, “survival”) none of them return a answer that made sense (ie not within 0 and 1

summary(surv_model, newdata = new_individual_a)

I initally thought it would work, but then i tried other combinations but then it seemed like the newdata arguement is ignored, since i tried very extreme values and they seems to have no change in the results.

survfit(mutli_cox_strat_fin, newdata = new_individual_a)

this returns: Call: survfit(formula = mutli_cox_strat_fin, newdata = new_individual_a)

      n events median 0.95LCL 0.95UCL

[1,] 104060 1635 NA NA NA so i dont know why it doesnt return anything constructive, but i saw online source saying that there wasnt enough half of them dying before the cutoff date. is there anything I could make it work?

0

There are 0 best solutions below