[R] flagging glm models with warnings

From: Caroline Paulsen <cpaulsen_at_u.washington.edu>
Date: Fri, 14 Dec 2007 11:35:48 -0800


I'm attempting to run 250 permutations of a negative binomial GLM model for data on fish counts. Many of the models are fit appropriately, but some issue warnings such as "convergence not reached" or "step size truncated due to divergence." I've attempted using glm.nb from the MASS package and the negbin function from the AOD package, but both still cause some models to experience errors and warnings.  

Examples of my 2 largest models, run from the 2 different functions  

negBin.glm1 <- glm.nb(Count ~ offset(log(Tow.Area)) + Basin + Bathy + Hypoxia + Period + Depth + Basin*Depth + Bathy*Depth + Hypoxia*Depth +

              Period*Depth + Basin*Period + Bathy*Period + Hypoxia*Period + Hypoxia:Period:Depth + Bathy:Period:Depth +

              Basin:Period:Depth, control=glm.control(maxit=1000), method="glm.fit", start=coefficients(hypoxia.glm1),

                data=Combined.Counts.df)

 

nb.glm1 <- negbin(Count ~ offset(log(Tow.Area)) + Basin + Bathy + Hypoxia + Period + Depth + Basin*Depth + Bathy*Depth + Hypoxia*Depth +

              Period*Depth + Basin*Period + Bathy*Period + Hypoxia*Period + Hypoxia:Period:Depth + Bathy:Period:Depth +

              Basin:Period:Depth,random = ~1, data=Combined.Counts.df, phi.ini = NULL, warnings = TRUE,

                na.action = na.omit, control = list(maxit = 100000))

 

I'd like to figure out a way to flag the models that have warnings and output them into either a table or into R console. Then I could evaluate the problems associated with these models and know not choose them as the best models for fitting the data.  

Since warnings() only calls the last.warning, I cannot figure out how to ask R if an error occurred for a particular model. I run all 250 models at once and then want to see which of them produced errors.  

Any suggestions on how to do this? Or suggestions on how to make my models not experience any warnings or errors?  

Thanks so much!    

Caroline E. Paulsen

School of Aquatic and Fishery Sciences

University of Washington

phone: 206.852.9539

email: cpaulsen_at_u.washington.edu  

        [[alternative HTML version deleted]]



R-help_at_r-project.org 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. Received on Fri 14 Dec 2007 - 19:37:50 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 14 Dec 2007 - 21:30:19 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.