Closed bwiernik closed 2 years ago
do you have a reproducible example with a model that has these components so I can play around?
Away from computer. The second example in ?glmmTMB
library(glmmTMB)
m <- glmmTMB(count ~ spp + mined + (1|site),
zi=~spp + mined,
family=nbinom2, data=Salamanders)
head(insight::get_predicted(m))
#> [1] 0.5387752 1.0768783 0.3554236 2.4701755 2.4950498 2.1819828
head(insight::get_predicted(m, type = "zprob"))
#> [1] 2.040119 2.040119 2.040119 1.174339 1.174339 1.174339
Created on 2021-08-04 by the reprex package (v2.0.0)
custom types should work after the latest commit.
So now it becomes a question or wether we want to change / add to the behaviour of our main predict
argument (this is also what would drive https://github.com/easystats/modelbased/issues/136). We could have predict = "dispersion"
or something like that, but then again I'm not very familiar with these models so I don't know
Yes, I think the predict argument should have options for zero inflated and dispersion parameters
I think we should revert the type
argument. Our predict
argument fills the same role, and it's confusing to have two.
Instead, I think we add options to predict
to include these:
Existing
type = "link"
Existing labels, need adjusted behavior
type = "response"
New labels
predict = "expectation"
"expectation"
for the zero-inflation part of the model"expectation"
for the zero-inflation part of the modeltype = "disp"
, glmmTMB returns estimates/CI on the sigma (SD) scale; I don't see a need to offer other scales (variance or log-variance [this is what is actually modeled])For predict = "prediction"
, we should include the dispersion parameter in the prediction intervals. @DominiqueMakowski If you could add a placeholder for that, I can fill in the necessary extractions from glmmTMB objects. How do we currently handle dispersion for things like Poisson models where there is a variance term in the model?
The needed steps to add/edit I believe are:
(essentially since we have one "master" argument predict, it is then passed to the .get_predicted_args()
helper that assigns the traditional arguments)
@DominiqueMakowski can insight be submitted, or is there anything that needs to be addressed for modelbased?
I wouldn't say that this issue of adding more options for glmmTMB is urgent so probably not a blocker for a CRAN update
I think this will be closed in #501
should be resolved in #501 to #503
Currently, for zero-inflated models,
get_predicted()
and its downstream functions likemodelbased::estimate_expectation()
always return the equivalent totype = "conditional"
(predicted values assuming non-zero). It would be good to allow users to specify other methods, such as predicting unconditional response predictions (incorporating both parts of the model) or just the zero-inflation parts.It would also be good I think to make the default equivalent to
type = "response"
(incorporating both model parts).See the
type
argument inpredict.glmmTMB()
: