0

I have reviewed the other similar questions and I don't believe I have found the answers.

I am trying to do Cox regression with two co-variates - sex and disease status.

Original data frame looks a bit like this:

Patient ID: 1001, 1002
Age: 56, 60
Sex: Male, Female
Mortality event: 1 0
Follow up years: 6,7

I have called cxmod <- coxph(Surv(Mortality event, time) ~ Disease_status + Sex, data = original data)

I have set up a dummy_df as a grid as per instructions for this package for the co-variates:

Sex Male  Disease_status 0, 
Sex  Female Disease_status 0, 
Sex Male Disease status 1, 
Sex Female Disease status 1

I have renamed the rownames as letters since I understood this is what was needed.

However when I call:

cxsf <- survfit(cxmod, data= orginal_data_frame, newdata = dummy_df, conf.type = "none")

I get the following error message:

Warning message:
'newdata' had 4 rows but variables found have 500000 rows 

Furthermore, if I call surv_summary(cxsf) to help visualise the plot - the R sessions gets terminated encountering a fatal error.

Can anyone advise on what's going wrong?

user63230
  • 4,095
  • 21
  • 43
Meercat
  • 1
  • 2
  • 1
    Welcome to SO,first provide some sample data, second format your question with crtl+k, also maybe ask this question in https://stats.stackexchange.com/ – Bruno Jan 03 '20 at 14:21

1 Answers1

0

You do not need to provide the original dataset to survfit because already the model has been trained using it and now the parameters exist in the model itself (cxmod).

survfit(cxmod , newdata = dummy_df, conf.type = "none")
Nareman Darwish
  • 1,251
  • 7
  • 14