Re: [R] Capture warning messages from coxph()

2007-12-18 Thread Terry Therneau
Xinyi Li asked how to keep track of which coxph models, called from within a loop, were responsible for warning messges. One solution is to modify the coxph code so that those models are marked in the return coxph object. Below is a set of changes to the final 40 lines of coxph.fit, that will ca

Re: [R] Capture warning messages from coxph()

2007-12-17 Thread jim holtman
One way is to turn the 'warnings' into 'errors' and then trap the error: > library(survival) > > time= c(4,3,1,1,2,2,3,3,2) > status=c(1,0,0,0,1,1,1,1,1) > TIME=Surv(time,status) > x= cbind(c(0,2,1,1,0,0,0,2,0),c(0,2,1,1,0,0,0,0,0)) > > results=matrix(NA,ncol=3,nrow=ncol(x)) > colnames(results)=c(

[R] Capture warning messages from coxph()

2007-12-17 Thread xinyi lin
Hi, I want to fit multiple cox models using the coxph() function. To do this, I use a for-loop and save the relevant results in a separate matrix. In the example below, only two models are fitted (my actual matrix has many more columns), one gives a warning message, while the other does not. Right