Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strange pattern in negative binomial GLMM residuals --> zero truncation #131

Closed
florianhartig opened this issue Dec 5, 2019 · 3 comments

Comments

@florianhartig
Copy link
Owner

florianhartig commented Dec 5, 2019

Question from a user

I'm using a mixed model with negative binomial distribution (with Poisson distribution the model has a clear overdispersion problem). Of the 5220 islands analyzed, 2158 have one species and 1113 have two species (see page 1 of the PDF file).

image

The high number of islands with few species seems to be causing problems in model adjustment (page 2), although the distribution of residuals by each original variable is reasonably balanced (page 3).

image

I imagine I have a problem equivalent to a zero inflation problem, but in my case, I have an inflation of 1's and 2's. As a test, I set to 0 the richness of all islands that have 1 or 2 species and adjusted a model similar to the previous one, however, with ziformula = ~ 1 to accommodate zero inflation. Model fit just got a lot better (pages 4 and 5), but I don't think that's the solution. Also, this last model is underdispersed and honestly I don't know how to handle it. I would love to hear your thoughts on this, as I imagine that you might have a better sense of what might be going on by looking at the simulation and the residuals.

image

@florianhartig
Copy link
Owner Author

florianhartig commented Dec 5, 2019

1) Distribution is zero-truncated

When you have lots of islands with 1/2, but no islands with zero species, the issue is not that your data is 1/2 inflated, but that it is zero-truncated, i.e. you have not enough zeros, likely because all the islands that have zero species were removed from your data.

I assume you didn't remove the data, probably islands with zero were never included in the database that you are using. In any case, such a response cannot fit to a neg binom, because this distribution will always predict zeros.

Ways to fix this:

  • Quick hack: subtract 1 from all your richness values
  • Better, but maybe more complicated solution: fit a zero-truncated model. I'm not sure what's available in standard packages, the hurdle model in glmmTMB might work

2) Notes about glmmTMB

I assume you use glmmTMB for your fits, at least for the zi-NB model? There is still this issue that REs in glmmTMB can create diagonal residuals. There is an updated to glmmTMB which fixes this, but this is not yet on CRAN. Details here #16, see limitations

@ElisaBarreto
Copy link

Dear Florian,

That's extremely helpful, thank you. Indeed, zero's were not included in the database because we are unsure they are true zeros. It does make perfect sense that what I need is a zero truncated model. The hurdle model in glmmTMB seems to be the way to go and its residuals look way better. But I'll not post them here because with the hurdle model I'm having convergence problems that I need to investigate further. Thank you for the help

@florianhartig
Copy link
Owner Author

Hi Elisa,

great, glad that this was useful!

Best,
F

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants