Dan Chaltiel
Dan Chaltiel

Reputation: 8503

How to select the default cluster in a Cox model in R?

I'm working on a Cox model and I have a variable which is cut in clusters.

Here is some working example :

lung2=lung
lung2$age.cl = cut(lung2$age, c(40,50,60,70,80,90))
cox = coxph(Surv(time, status) ~ age.cl, data =  lung2)

It returns this table :

                coef exp(coef) se(coef)    z     p
age.cl(50,60]  0.184     1.202    0.297 0.62 0.536
age.cl(60,70]  0.237     1.267    0.288 0.82 0.411
age.cl(70,80]  0.532     1.703    0.309 1.73 0.085
age.cl(80,90]  3.926    50.707    0.825 4.76 2e-06

By default, coxph calculate everything with the first cluster as default. But what if the clinical default were 70-80yo and not 40-50yo ?

How can I tell coxph to take the n'th cluster as default ?

Upvotes: 0

Views: 186

Answers (1)

Andrew Taylor
Andrew Taylor

Reputation: 3488

lung2=lung
lung2$age.cl = cut(lung2$age, c(40,50,60,70,80,90))
lung2$age.cl_relevel <- relevel(lung2$age.cl, '(70,80]')
cox = coxph(Surv(time, status) ~ age.cl_relevel, data =  lung2)

Upvotes: 1

Related Questions