rvlenth / emmeans

Estimated marginal means
https://rvlenth.github.io/emmeans/
358 stars 31 forks source link

Zero-Inflated Models #293

Closed delucalab closed 3 years ago

delucalab commented 3 years ago

Using the emmeans package, is it possible to estimate the actual mean response using the data from both the conditional and zi components of a particular model?

rvlenth commented 3 years ago

I don't know. It depends on what you used to fit the model. See vignette("models", "emmeans") and see what options are available. Some packages provide their own emmeans support, in which case it's documented in that package.

delucalab commented 3 years ago

I'm fitting zero-inflated models with glmmtmb and it looks like only fixed effects can be taken into account when computing the marginal means but I wasn't sure if I was missing anything more nuanced to compute the marginal means taking other aspects of variance into account (ie zero-inflation and random effects)?

rvlenth commented 3 years ago

Correct. EMMs are computed only with fixed effects. You could try fitting a different model with the effects of interest included in the fixed effects.

rvlenth commented 3 years ago

I'm kind of laggy in commenting on this, but in a zero-inflated model, it is quite reasonable to want to estimate the actual mean response, which is (1 - p) * mu, where p is the probability of a zero and mu is the estimated response from the linear predictor (usually via back-transforming from the link). In a very few cases (e.g., zeroinfl objects from the pscl package -- see vignette("models", "emmeans")), that is available in emmeans(). It's really messy to program it. It'd be nice if that were included in **glmmTMB` support, but I don't think it is.

rvlenth commented 3 years ago

I think I'll close this issue, as I think it is resolved as much as I can from this end.