Coder Social home page Coder Social logo

Comments (1)

strengejacke avatar strengejacke commented on June 24, 2024

Thanks for reporting this issue. This was indeed unclear. I revised test_predictions(), and you should now be able to compute contrasts / comparisons for the different model components of zero-inflation-models.

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

from ggeffects.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.