-
Notifications
You must be signed in to change notification settings - Fork 34
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
test_predictions() for zero inflated model #534
Comments
Thanks for reporting this issue. This was indeed unclear. I revised This is how it looks like: library(ggeffects)
data(Salamanders, package = "glmmTMB")
m <- glmmTMB::glmmTMB(
count ~ mined + (1 | site),
ziformula = ~mined,
family = poisson(),
data = Salamanders
)
# count-model
pr <- predict_response(m, "mined")
pr
#> # Predicted counts of count
#>
#> mined | Predicted | 95% CI
#> ------------------------------
#> yes | 1.09 | 0.69, 1.72
#> no | 3.42 | 2.86, 4.09
#>
#> Adjusted for:
#> * site = NA (population-level) test_predictions(pr)
#> # Pairwise comparisons
#>
#> mined | Contrast | 95% CI | p
#> -----------------------------------------
#> yes-no | -2.39 | -3.18, -1.60 | < .001
#>
#> Contrasts are presented as conditional means. # full model (count and zero-inflation)
pr <- predict_response(m, "mined", type = "zero_inflated")
pr
#> # Predicted counts of count
#>
#> mined | Predicted | 95% CI
#> ------------------------------
#> yes | 0.26 | 0.12, 0.41
#> no | 2.21 | 1.77, 2.64
#>
#> Adjusted for:
#> * site = NA (population-level) test_predictions(pr)
#> # Pairwise comparisons
#>
#> mined | Contrast | 95% CI | p
#> -----------------------------------------
#> yes-no | -1.99 | -2.41, -1.58 | < .001
#>
#> Contrasts are presented as counts. # zero-inflation-probabilities
pr <- predict_response(m, "mined", type = "zi_prob")
pr
#> # Predicted zero-inflation probabilities of count
#>
#> mined | Predicted | 95% CI
#> ------------------------------
#> yes | 0.76 | 0.66, 0.83
#> no | 0.36 | 0.30, 0.41
#>
#> Adjusted for:
#> * site = NA (population-level) # no CIs for default engine
test_predictions(pr)
#> # Pairwise comparisons
#>
#> mined | Contrast | 95% CI | p
#> ------------------------------
#> yes-no | 0.40 | |
#>
#> Contrasts are presented as probabilities. # use "ggeffects" for CI
test_predictions(pr, engine = "ggeffects")
#> # Pairwise comparisons
#>
#> mined | Contrast | 95% CI | p
#> ---------------------------------------
#> yes-no | 0.40 | 0.30, 0.50 | < .001
#>
#> Contrasts are presented as probabilities. Created on 2024-06-04 with reprex v2.1.0 |
strengejacke
added a commit
that referenced
this issue
Jun 4, 2024
* test_predictions() for zero inflated model Fixes #534 * version * fix * trigger CI * fix * Update DESCRIPTION * Update DESCRIPTION * Add test * fix, tests * default option * fix * fix tests * docs * news
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you so much for developing this useful package for various analyses. I'm working on zero inflated negative binomial model with glmmTMB, and I used predict_response() for both the zero inflated part and the count part. Now I need to perform pairwise compare between levels of my predictor, so I used test_predictions(), but when I use the prediction from either the zero part or count part, the function results are the same. I was expecting different results for zero part and count part. My example codes as below:
for the predict_response I can set a "type" parameter to indicate which part of the component I want to condition on, is there anything similar I can do for the test_predictions? If no extra parameter used, which part of the model used for pairwise comparison?
The text was updated successfully, but these errors were encountered: