Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

how to get SE value from R coxph

I’m trying to extract the SE value from a coxph object, expanding from https://stats.stackexchange.com/questions/324042/get-standard-error-of-exponentiated-coefficient-in-cox-regression:

library(survival)
library(survey)

res.cox <- coxph(Surv(time, status) ~ sex, data = lung)

which shows a nice coxph object:

> res.cox
Call:
coxph(formula = Surv(time, status) ~ sex, data = lung)

       coef exp(coef) se(coef)      z       p
sex -0.5310    0.5880   0.1672 -3.176 0.00149

Likelihood ratio test=10.63  on 1 df, p=0.001111
n= 228, number of events= 165

However, I need a way to extract the se(coef) value, and I don’t know how to do that through res.cox, and such an extraction may not be possible, so I use survey:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

s <- svycontrast(res.cox, quote(exp(sex)))

which looks like

> s
         nlcon     SE
contrast 0.588 0.0983

but the SE value is wrong!

How can I get the se(coef) value from res.cox?

>Solution :

If you run summary on a coxph object, you get a list-like object that contains several members, including the coefficients table. You can pluck out the se(coef) column with standard indexing, so in your example you could get at the se with:

summary(res.cox)$coefficients[,"se(coef)"]
#> [1] 0.1671786
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading