[R] discrepancies between stata and r for a cox regression

Gary Collins collins.gs at gmail.com
Mon May 18 18:26:27 CEST 2009


try

res <- coxph(Surv(TIME, STATUS)~TREAT, data=leukemia, method="breslow")

R default for handling ties is Efron's method, whereas it's Breslow for 
STATA.

Have a look under method in ?coxph it clearly states this, and STATA 
output clearly states the Breslow method for ties in the output of 
running a cox model.

HTH

Gary
---------------------------------------------------------------
Dr Gary S Collins                       Tel: +44 (0)1865 284418
Centre for Statistics in Medicine       Fax: +44 (0)1865 284424
Wolfson College Annexe                    www.csm-oxford.org.uk
University of Oxford
Linton Road
Oxford, OX2 6UD
---------------------------------------------------------------

Michel Boutsen wrote:
> Hello
> 
> 
> I would like to develop the use of R.
> Trying R and more particulary the cox model, I am surprised by discrepancies between results with stata and R for a cox model
> 
> With the same data base, I get a hazard ratio (4.82) that is not the same obtained with stata (4.52)
> 
> You will find attached the file leukemia.dta I used (Stata)
> 
> Here are the codes for R
> 
> leukemia=read.fwf(file="leukem.txt",widths=c(4,2,3,2,5,2),col.names=c("id","TREAT","TIME","STATUS","LOGWBC", "GENDER"))
> library(survival)
> res <- coxph(Surv(TIME, STATUS)~TREAT, data=leukemia)
> summary(res)
> 
> 
> and here the codes for for stata
> 
> infix ID 2-3 TREAT 6 TIME 8-9 STATUS 11 LOGWBC 12-16 GENDER 18 using "g:rleukem.txt",clear
> stset TIME, failure(STATUS==1)
> stcox TREAT
> 
> SPSS and EPIinfo give the same HR than Stata
> 
> I tried with an other database without any problem
> 
> What would be the problem??? I changed of pc and versions of R (2.81 & 2.9.0) without any change. The means are the same for the two packages.
> 
> I saw a few posts with discrepancies but not with the same database
> 
> Thanks in advance
> 
> Michel Boutsen
> Brussel's University
> Department of Biostatistics 
> 
> 
> ------------------------------------------------------------------------
> 
> ______________________________________________
> 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