Re: [R] Re: errors in randomization test

From: Peter Dalgaard <>
Date: Tue 06 Jul 2004 - 22:13:07 EST

"CR Bleay, School Biological Sciences" <> writes:

> hello all,
> last week i sent an e-mail about dealing with errors thrown up from a

> glm.nb model carried out on multiple random datasets.

> every so often a dataset is created which results in the following

> error after a call to glm.nb:

> "Error: NA/NaN/Inf in foreign function call (arg 1)

> In addition: Warning message:

> Step size truncated due to divergence"

> I am at a loss as to how to deal with this.

> firstly because the dataset that is generated, although throwing an

> error when the glm.nb model is applied, is a valid dataset. so how do

> i incorporate this dataset in my results (results being descriptive

> stats on the coefficients from the multiple datasets) i.e. shoould

> coefficients be set to zero?

NA, more likely, but it's not easy to say in general. If the algorithm diverged in a particular way, setting diverged parameters to Inf or -Inf might be a better idea. It is of course, quite normal that the MLE does not exist for some data sets, although perhaps the algorithm might have failed more gracefully.

> secondly, how do i capture and deal with the error. is it possible to
> construct an "if" statement so that "if error, do this, if not
> continue"
> lastly, i am unsure as to what characteristics of a dataset would

> result in these errors in the glm.nb?
> i would be very grateful for any assistance on this matter. i having
> been staring at code for too many days now and so can't see the wood
> for the trees.

Look at try()

   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (             FAX: (+45) 35327907

______________________________________________ mailing list
PLEASE do read the posting guide!
Received on Tue Jul 06 22:18:37 2004

This archive was generated by hypermail 2.1.8 : Wed 03 Nov 2004 - 22:54:43 EST