I have a set of fish data from a lake. I am trying to see whether the local fish community differs depending on the location within the lake (North, East, West), the presence of an island at the sampling location (Yes/No), or via an interaction effect between the two. Sampling within the lake was uneven.

I'm running a multivariate ANOVA with the mvabund package in R. Initially I was converting the catch data to catch per unit effort (number of individuals of each species/number of sampling events). This seemed to be working fine and I was getting results that made sense, but the model would generate a warning saying "non-integer data are fitted to the negative.binomial model". I read that this was an issue that stemmed from converting the count data to catch per unit effort, and the more appropriate approach is to just use the straight count data and apply an offset to the model equal to the number of samples collected at each location. When I do this though my model takes forever to run and I get many versions of the message: l=nan, theta=1000000.0000, yi=0.0000, mu=nan. This happens even when I decrease the number of iterations from 9,999 to 2. Any idea what's going on here/how to fix it?

library(mvabund) #for multivariate GLMs
# Load .csv file with species as columns and sampling location/year
# as rows. Values are number of individuals captured.
Community <- read.csv(file = "Island Group By Year.csv", 
                      header = TRUE)

# Take the subset of the data so it's just species abundances 
# (other columns identify the location, presence of an island, 
# year and number of samples taken)
Community_spp <- mvabund(Community[,7:42])

# Establish your factors
Year <- as.numeric(Community$Year)
Location <- Community$Location
Island <- Community$Has.Island
Offset <- Community$Number.of.samples

# Build the model:
mod1 <- manyglm(Community_spp ~ Island*Location, block = Year, 
                family="negative_binomial", offset = Offset)

# Run the ANOVA
anova(mod1, p.uni="unadjusted", nBoot = 999)

This works and produces a result that makes sense if I use catch per unit effort data instead of using the offset approach.

  • $\begingroup$ You need at least to show us the code you tried for this to be answerable (and on-topic). mvabund have many functions, and you did'nt tell us what you tried! $\endgroup$ Apr 20, 2021 at 16:09

2 Answers 2


It is also important to convert your interaction variable (if they look like numeric) to factors. My problem with this was solved after I converted them to factors.

  • $\begingroup$ I have both individual components of the interaction coded as factors. I don't think there's a way to code the combination of the two as a factor as well. Even running it that way I get the same issue. $\endgroup$
    – Dugan
    Oct 27, 2021 at 0:50

You may need to log transform the input variable (Number.of.samples) you're using for your offset variable, to match the log link function of the negative binomial.

Here is a link to an mvabund tutorial in which the author uses a log-transformed offset. https://pdixon.stat.iastate.edu/stat534/R/mvabund.pdf

And here is a CV post with a nice answer about using offsets in general, specifying that the input variable used for the offset should be log-transformed before adding it to the function. Should I use an offset for my Poisson GLM?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.