Closed AlissonRP closed 2 years ago
I don't think you have read the documentation. Subscripts of a cox.zph object do a very particular thing. It doesn't happen to be what you want to assume.
A primary use:
fit <- coxph(Surv(time, status) ~ age + sex + ph.ecog, data= lung)
zp <- cox.zph(fit)
plot(zp[1])
This will draw a plot of the ph test for age.
Your example asks for the second variable, for a model that has only one. Of course it failed.
Sorry, so the index is just for plot
? but how to "collect" the values in the last line of cox.zph
??
Edit: is in cox.zph$table
When we apply the
cox_zph
function it returns an object of the classcox.zph
which is ultimately alist
, but indexing doesn't seem to be working well (or is intentional???), because if I want to select the last line (GLOBAL), its output an error:So in this pr I made a slight adjustment in this function:
I didn't do a lot of testing, so reviews are welcome.