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

Pattern in RE-grouped residual for binomial GLMM #412

Open
florianhartig opened this issue May 28, 2024 · 2 comments
Open

Pattern in RE-grouped residual for binomial GLMM #412

florianhartig opened this issue May 28, 2024 · 2 comments

Comments

@florianhartig
Copy link
Owner

Question via email

I'm using the DHARMa package to check the residuals of my binomial (0/1) generalized additive models for my master thesis project, and I'm having some difficulties interpreting the results. When I run the main plots, I obtain these results:

image

I followed what is suggested in the manual and tried to group the residuals. I have 4 natural grouping variables: 2 RE and 2 temporal (year and month), and my model include all these 4 variables and some other continuous predictors. If I understood it correctly, when I group (e.g by one of the RE) the plots indicate some underdispersion? My main doubts is related with the plot on the right (residuals vs. predictions). What does it indicate about the model? Is these residual pattern concerning?

image

@florianhartig
Copy link
Owner Author

Hello,

this doesn't look super concerning to me, but it does confirm the point in the vignette that you can have perfectly fine patterns per data point, but once you look per group you see certain patterns.

Before interpreting the pattern, I wanted to check that this is not a fluke, because RE estimates are known to be biased towards the mean, so was considering if a pattern could emerge from that. I therefore played around with variations of the following code:

testData = createData(sampleSize = 500, 
                      overdispersion = 0, 
                      family = binomial(), 
                      randomEffectVariance = 2, 
                      numGroups = 100)

library(lme4)
fit <- glmer(observedResponse ~ Environment1 + (1|group), 
             family = "binomial", data = testData)

summary(fit)


res <- simulateResiduals(fit, plot = T)
res2 <- recalculateResiduals(res, group = testData$group)
plot(res2)

I didn't really see any spurious patterns emerge. Thus, I would conclude that this is real and that you have a bit of underdispersion and a bit of heteroskedasticity in your RE-grouped residuals.

Underdispersion is often as sign of overfitting, so it could be that you have quite a lot of REs in relation to your number of observations, and thus your REs overfit a bit. As underdispersion is usually conservative (i.e. your p-values are larger than they should be), I would not be concerned about this, i.e. I would think the model is probably still acceptable, but you could consider.

Feel free to comment on this. I'll leave this issue open as a reminder to check in a bit more detail if it's a good idea to group by RE, and to add comments on this in the vignette!

@florianhartig florianhartig changed the title Residual pattern in grouped binomial GLMM Pattern in RE-grouped Residual for binomial GLMM May 28, 2024
@florianhartig florianhartig changed the title Pattern in RE-grouped Residual for binomial GLMM Pattern in RE-grouped residual for binomial GLMM May 28, 2024
@mines-silva
Copy link

Thank you so much for your answer!

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