Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 205301

Warning: 'newdata' has x rows but variables found have >x rows with coxph and survfit

$
0
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?


Viewing all articles
Browse latest Browse all 205301

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>