I need to extract the p
attribute of a specific row in the output of cox.zph
function in R.
To put you in question, I describe my problem as follows, step by step with an example:
require('survival')
# I create the simplest test data set
test1 <- list(time=c(4,3,1,1,2,2,3),
status=c(1,1,1,0,1,1,0),
x=c(0,2,1,1,1,0,0),
sex=c(0,0,0,0,1,1,1))
# Fit a stratified model
coxmodel <- coxph(Surv(time, status) ~ x + strata(sex), test1)
And then, I use cox.zph
function:
zph <- cox.zph(coxmodel)
With the following output:
rho chisq p
x 0.354 0.322 0.57
I tried to get p
attribute value (in this case, 0.57) by using attributes(zph)
but p
doesn't appear in order to do something like zph$p
. I also used plyr
package with no results.
Does anyone could help me? Thanks.