Open strengejacke opened 4 years ago
What would be necessary to support it correctly? Does emmeans deals with it alright?
No, I don't think this is supported by emmeans yet (resp. glmmTMB, which implements emmeans functionality).
It's not that hard, I'd say...
1) simulate predictions: prdat.sim <- .simulate_predictions(model, newdata, nsim, terms, value_adjustment, condition)
(https://github.com/strengejacke/ggeffects/blob/f5f3056103940ecb53b8a44496e1804b29de7d39/R/predict_zero_inflation.R#L161)
2) calculate predictions for "overall" model: sims <- exp(prdat.sim$cond) * (1 - stats::plogis(prdat.sim$zi))
3) compute quantiles (SD, 95% quantiles for CI...): prediction_data <- .join_simulations(data_grid, newdata, prdat, sims, ci, cleaned_terms)
(https://github.com/strengejacke/ggeffects/blob/f5f3056103940ecb53b8a44496e1804b29de7d39/R/predict_zero_inflation.R#L2).
The code I used was "evolving" over time, so could possibly be more clean, but it is stable and works with edge cases ;-)
What you see under 2), is what you already get. However, the CIs/SEs are wrong, that's why all the simulation stuff is done here.
is this issue still valid? Does it have anything to do with get_predicted?
Yes, if you want to have the "correct" CI, we still haven't addressed this, I think.
One thing that is rather difficult is the "overal" estimated means from a model, i.e. the count component conditioned on the zi-component:
Created on 2020-06-22 by the reprex package (v0.3.0)
Brooks ME, Kristensen K, Benthem KJ van, Magnusson A, Berg CW, Nielsen A, et al. glmmTMB Balances Speed and Flexibility Among Packages for Zero-inflated Generalized Linear Mixed Modeling. The R Journal. 2017;9: 378-400.
Originally posted by @strengejacke in https://github.com/easystats/modelbased/issues/66#issuecomment-647532231