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

underdispersion in nbinominal GLMM #459

Open
NimoLululu opened this issue Dec 25, 2024 · 2 comments
Open

underdispersion in nbinominal GLMM #459

NimoLululu opened this issue Dec 25, 2024 · 2 comments

Comments

@NimoLululu
Copy link

NimoLululu commented Dec 25, 2024

Hi @florianhartig,

First of all, thank you for bringing DHARMa to our work – it's been incredibly helpful!

I have encountered dispersion issues while fitting a GLMM using glmmTMB. Initially, I aimed to explore the relationship between prevalence (defined as infectedbird / totalbird) and explanatory variables. I started with the following code:

modelone <-gimmtmB(cbind(infectedbird, totalbird - infectedbird) ~ latitude + longitude + season*route + (1 | ID)+(1 | birdsp),family= binomial(link ="logit")),

However, an overdispersion issue was detected. To address this, I adjusted the model to a negative binomial GLMM:

modeltwo<- glmmTMB(infectedbird ~ latitude + longitude + season * route + (1 | birdsp) + (1 | ID)+offset(log(totalbird)),family = nbinom2(link = "log")).

After running the dispersion test, I found an underdispersion issue instead:

testDispersion(modeltwo)
DHARMa nonparametric dispersion test via sd of residuals fitted vs. simulated
data: simulationOutput
dispersion = 0.23962, p-value = 0.44

image
image
image

I would appreciate any insights into addressing the underdispersion.

TIA,
Nimo

@NimoLululu
Copy link
Author

Update:

I tried to correct the misfits by adding splines, then it seems that the predictors match the quartile lines. However the model is still underdispersion.

model2 <- glmmTMB(infectedbird ~ ns(latitude, df = 3) + longitude+ season * route + (1 | birdsp) + (1 | ID) + offset(log(totalbird)), family = nbinom2(link = "log"))

image
image
image

@melina-leite
Copy link
Collaborator

Hi @nimolulu,

First, overdispersion may arise not only from "real" overdispersion in the data but also from model misspecification. Before moving to a different model, I'd suggest further investigations in your current binomial model. For example, have you checked for heteroscedasticity in your model predictors? Or could you suspect a zero inflation in the proportion of infected birds?

Second, discarding the easiest misspecification problems, I'd use a different dispersion test. For GLMMs, the default dispersion test in DHARMa may not be the most appropriate (See more detailed on the tests in the vignette of the package and the testDispersion and simulateResiduals help files.). You could use:

  1. the nonparametric version of the Pearson residuals chisquared test, by simulating residuals with refit=T. Depending on your model and data amount it may cost a lot of time:
res <- simulateResiduals(fittedModel, refit=T) 
testDispersion(res)
  1. simulate residuals conditional on the Random Effects, which in glmmTMB is a bit tricky but with a recent alternative implemented (package version 1.1.10) it became possible:
glmmTMB::set_simcodes(fittedModel$obj, val = "fix")

res <- simulateResiduals(fittedModel)
testDispersion(res)


# this is equivalent of doing this in lme4 package:
res <- simulateResiduals(fittedModel, re.form=NULL)

Third, if your model is really overdispersed, I'd use a beta-binomial model as an alternative to your binomial model (https://peerj.com/articles/1114/).

I hope this helps you in your modeling.
let me know if you have further comments or questions
:)

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