[R] exclude the unfit data from the iteration

Mohammad Ehsanul Karim wildscop at yahoo.com
Wed Apr 25 00:32:44 CEST 2007

Dear List, 

Trying to explain my situation as simply as possible
for me:

I am running a series of iteration on coxph model on
simulated data (newly generated data on each iteration
to run under coxph; in my example below- sim.fr is the
generated data). However, sometimes i get warning
messages like 
"Ran out of iterations and did not converge" or 
"Error in var(x, na.rm = na.rm) : missing observations
in cov/cor" 
because in some cases one of my covariate (say, var5
or var6 or both who are binary variables) becomes all

How do I exclude the unfit data (that does not
fit/converge: that produces warning messages) that may
be generated in any iteration, and still continue by
replacing it by the next iteration data (untill it
generates acceptable data that does not give any
trouble like not converging)? Is there any provision
in R?

"sim.result" <- function(...){
fit.gm.em <- coxph(Surv(times,censored) ~
var1+var2+var3+var4+var5+var6 +
frailty(id,dist='gamma', method='em'), data= sim.fr)

I know
can hide warning messages, but I need not hide the
problem, all i need to do is to tell the program to
continue untill fixed number of times (say, 100) it
iterates with good data.

Thank you for your time.

Mohammad Ehsanul Karim (R - 2.3.1 on windows)
Institute of Statistical Research and Training
University of Dhaka

More information about the R-help mailing list