[R] exclude the unfit data from the iteration
Bert Gunter
gunter.berton at gene.com
Wed Apr 25 02:00:46 CEST 2007
?try
Wrap each iteration in a try() call
Also ?tryCatch if you want to get fancy -- and can understand the rather
arcane docs.
Bert Gunter
Genentech Nonclinical Statistics
-----Original Message-----
From: r-help-bounces at stat.math.ethz.ch
[mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Mohammad Ehsanul
Karim
Sent: Tuesday, April 24, 2007 3:33 PM
To: r-help at stat.math.ethz.ch
Subject: [R] exclude the unfit data from the iteration
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
0's!
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
options(warn=-1)
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
______________________________________________
R-help at stat.math.ethz.ch 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