[R] About 'hazard ratio', urgent~~~
Mike Marchywka
marchywka at hotmail.com
Tue Jun 14 12:34:21 CEST 2011
----------------------------------------
> Date: Mon, 13 Jun 2011 19:44:15 -0700
> From: dr.jzhou at gmail.com
> To: r-help at r-project.org
> Subject: [R] About 'hazard ratio', urgent~~~
>
> Hi,
>
> I am new to R.
>
> My question is: how to get the 'hazard ratio' using the 'coxph' function in
> 'survival' package?
You can probably search the docs for hazard terms, for example,
http://cran.r-project.org/doc/contrib/Fox-Companion/appendix-cox-regression.pdf
and try running known test data through to verify. For example,
it does seem that the "exp" column contains a decent estimate of hazard
ratio in simple cases( not quite right 3 sig figs but haven't given this
a lot of thought and it is still early here, hoping from input from someone
who can explain better) ,
> ?rexp
> ns=100000
> df<-data.frame(gr<-c(rep(0,ns),rep(1,ns)),t=c(rexp(ns,1),rexp(ns,3)))
> coxph(Surv(t)~gr,df)
Call:
coxph(formula = Surv(t) ~ gr, data = df)
coef exp(coef) se(coef) z p
gr 1.09 2.98 0.00503 217 0
Likelihood ratio test=47382 on 1 df, p=0 n= 200000, number of events= 2e+05
> df<-data.frame(gr<-c(rep(0,100),rep(1,100)),t=c(rexp(100,1),rexp(100,2)))
> coxph(Surv(t)~gr,df)
Call:
coxph(formula = Surv(t) ~ gr, data = df)
coef exp(coef) se(coef) z p
gr 0.658 1.93 0.148 4.44 8.8e-06
Likelihood ratio test=19.6 on 1 df, p=9.5e-06 n= 200, number of events= 200
> df<-data.frame(gr<-c(rep(0,100),rep(1,100)),t=c(rexp(100,1),rexp(100,1)))
> coxph(Surv(t)~gr,df)
Call:
coxph(formula = Surv(t) ~ gr, data = df)
coef exp(coef) se(coef) z p
gr -0.0266 0.974 0.142 -0.187 0.85
Likelihood ratio test=0.03 on 1 df, p=0.852 n= 200, number of events= 200
>
>
> thanks,
>
> karena
>
> --
> View this message in context: http://r.789695.n4.nabble.com/About-hazard-ratio-urgent-tp3595527p3595527.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list