Nope - that does not work. The value of last.warning is not reset after the initial NULL.
Ravi. ____________________________________________________________________ Ravi Varadhan, Ph.D. Assistant Professor, Division of Geriatric Medicine and Gerontology School of Medicine Johns Hopkins University Ph. (410) 502-2619 email: [email protected] ----- Original Message ----- From: Ravi Varadhan <[email protected]> Date: Friday, February 18, 2011 11:35 am Subject: Re: [R] How to flag those iterations which yield a warning? To: Ravi Varadhan <[email protected]> Cc: [email protected] > May be I could do: > > for (i in 1:nsim) { > > last.warning <- NULL > > # do model fitting > > if(!is.null(last.warning)) # discard simulation result > > } > > I think this might work. Any other ideas? > > Ravi. > > ____________________________________________________________________ > > Ravi Varadhan, Ph.D. > Assistant Professor, > Division of Geriatric Medicine and Gerontology > School of Medicine > Johns Hopkins University > > Ph. (410) 502-2619 > email: [email protected] > > > ----- Original Message ----- > From: Ravi Varadhan <[email protected]> > Date: Friday, February 18, 2011 11:29 am > Subject: [R] How to flag those iterations which yield a warning? > To: [email protected] > > > > Hi, > > > > I am running a simulation study with the survival::coxph. Some of > > > the simulations result in problematic fits due to flat partial > > likelihood. So, you get the warning message: > > > > Warning message: > > In fitter(X, Y, strats, offset, init, control, weights = weights, > > > ... : > > Loglik converged before variable 2 ; beta may be infinite. > > > > How can I keep track of the simulations which yield any kind of > > warning message, so that I can appropriately handle them in the > > post-processing of simulation results? > > > > I know that `try' can be used to capture errors, but I would like > to > > capture and detect warnings. > > > > Any pointers would be appreciated. > > > > Thanks, > > Ravi. > > ____________________________________________________________________ > > > > Ravi Varadhan, Ph.D. > > Assistant Professor, > > Division of Geriatric Medicine and Gerontology > > School of Medicine > > Johns Hopkins University > > > > Ph. (410) 502-2619 > > email: [email protected] > > > > ______________________________________________ > > [email protected] mailing list > > > > PLEASE do read the posting guide > > and provide commented, minimal, self-contained, reproducible code. > ______________________________________________ [email protected] 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.

