-
-
Notifications
You must be signed in to change notification settings - Fork 94
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
check_zeroinflation() wrong results with glmmTMB Ngative Binomial #367
Labels
Bug 🐛
Something isn't working
Comments
An easy solution could be # get theta
if(is(x, "glmmTMB")){
theta <- stats::sigma(x)
} else {
theta <- x$theta
}
mu <- stats::fitted(x)
if (model_info$is_negbin && !is.null(theta)) {
pred.zero <- round(sum(stats::dnbinom(x = 0, size = theta,
mu = mu)))
} Note that in the case of From previous example
|
Thanks, your suggestion looks good! |
bwiernik
added a commit
that referenced
this issue
Sep 20, 2021
Closes #367 Co-Authored-By: Claudio Zandonella Callegher <[email protected]>
Hi, I'm not sure if this was really fixed, see florianhartig/DHARMa#392 |
15 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for this amazing package!
I found a small issue concerning
performance::check_zeroinflation()
with models obtained fromglmmTMB::glmmTMB()
using Negative Binomial distributions.Minimal Working Example
I fitted two models on the same data specifying a negative binomial distribution using respectively
MASS::glm.nb()
andglmmTMB::glmmTMB()
. As you can see estimated parameters are identical.Results from
performance::check_zeroinflation()
, however, are very different:This is a problem as the model are identical (almost). Digging into the code, I found that the problem in this part of the code
performance/R/check_zeroinflation.R
Lines 47 to 52 in 371f1bb
where
x
is the model fit. Note thatx$theta
works fine forglm.nb
objects but notglmmTMB
objectsTo properly get the dispersion parameter from
glmmTMB
objects, the functionstats::sigma()
can be used:Failing to get
x$theta
, the function actually ends up evaluating density from a Poisson distribution, rather than negative binomial (see code linked).Note that this issue may affect other functions as well where the dispersion parameter is involved
The text was updated successfully, but these errors were encountered: