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@u.washington.edu
[[alternative HTML version deleted]]