-
-
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_model() and other functions not working with only post-"hurdle" glmmTMB model #781
Comments
Thanks for reporting, and the reproducible example! Will look into this. |
Seems to work now, but not sure if the output is sensible? data(Salamanders, package = "glmmTMB")
mod_trunc_error <- glmmTMB::glmmTMB(
count ~ spp + mined + (1 | site),
data = Salamanders[Salamanders$count > 0, , drop = FALSE],
family = glmmTMB::truncated_nbinom2(),
ziformula = ~ 0,
dispformula = ~ 1
)
performance::check_collinearity(mod_trunc_error)
#> # Check for Multicollinearity
#>
#> * conditional component:
#>
#> Low Correlation
#>
#> Term VIF VIF 95% CI Increased SE Tolerance Tolerance 95% CI
#> spp 1.03 [1.00, 2.32] 1.02 0.97 [0.43, 1.00]
#> mined 1.03 [1.00, 2.32] 1.02 0.97 [0.43, 1.00] Created on 2024-11-26 with reprex v2.1.1 |
Important: In my initial post, I forgot to filter the dataset for zeros in the It should be
Instead of
Whats the best practice here? |
To @strengejacke's solution: As stated before I'm not a person with solid statistical knowledge, but I guess that did the trick. My understanding is that the vif results of the post-hurdle only model should be the same as the conditional component of the whole hurdle model, which seems to be the case, comparing the output of the corrected library(glmmTMB)
library(easystats)
library(tidyverse)
library(reprex)
#> Warning: package 'reprex' was built under R version 4.4.2
mod_whole<-glmmTMB(count~spp+mined+(1|site)+(1|spp),
data=Salamanders%>%filter(count>0), family="truncated_nbinom2",
ziformula = ~1, dispformula = ~1)
check_collinearity(mod_whole)
#> # Check for Multicollinearity
#>
#> * conditional component:
#>
#> Low Correlation
#>
#> Term VIF VIF 95% CI Increased SE Tolerance Tolerance 95% CI
#> spp 1.03 [1.00, 2.30] 1.02 0.97 [0.43, 1.00]
#> mined 1.03 [1.00, 2.30] 1.02 0.97 [0.43, 1.00]
check_model(mod_whole, panel=F)
#> `check_outliers()` does not yet support models of class `glmmTMB`. Created on 2024-11-27 with reprex v2.1.1 But maybe someone with a deeper understanding of the P.S: I also want to say a big thank you to all contributors of this awesome package; the package and its documentation helped me a lot. |
Doesn't matter, I have a reproducible example and added a test, so no need to edit the posts.
Great! I'll merge the PR once all tests pass. |
(First time opening an issue on github, please bear with me)
Foreword: I'm a trained entomologist, with statistical and R-knowledge gathered through "learning by doing", so if this is just user error, I want to apologise in advance.
Stumbled upon this error, using a
glmmTMB
model with only the truncated "post hurdle" part (lacking a better descriptor):Error: check_model() returned following error: 'data' must be of a vector type, was 'NULL'
As far as I understand it, the usage of the
truncated_nbinom2
family argument leads to this error, if thezi-component
is deactivated.Creating the model which produces the error:
Created on 2024-11-26 with reprex v2.1.1
Creating a whole hurdle model working fine (plotting deactivated; works as intended):
Created on 2024-11-26 with reprex v2.1.1
Creating a post-hurdle model but with "normal" negbin2-family instead of the truncated version working fine (plotting deactivated; works as intended):
Created on 2024-11-26 with reprex v2.1.1
Session info
Created on 2024-11-26 with reprex v2.1.1
The text was updated successfully, but these errors were encountered: