Open strengejacke opened 5 months ago
We have following deviation to MuMIn:
However, the things we do differently are in line with the code in the Supplement 2 of Nakagawa. Thus, I would say we go with the current implementation of get_variance()
. I added lots of tests to validate against external evidence of correct results.
@bbolker null_model()
probably doesn't calculate the correct null model for zero-inflation models. What would be the correct null model in the next example?
data(fish, package = "insight")
m1 <- glmmTMB::glmmTMB(
count ~ child + camper + (1 | persons),
ziformula = ~ child + camper + (1 | persons),
data = fish,
family = poisson()
)
summary(insight::null_model(m1))
#> Family: poisson ( log )
#> Formula: count ~ (1 | persons)
#> Zero inflation: ~child + camper + (1 | persons)
#> Data: fish
#>
#> AIC BIC logLik deviance df.resid
#> 1808.7 1829.8 -898.3 1796.7 244
#>
#> Random effects:
#>
#> Conditional model:
#> Groups Name Variance Std.Dev.
#> persons (Intercept) 0.6808 0.8251
#> Number of obs: 250, groups: persons, 4
#>
#> Zero-inflation model:
#> Groups Name Variance Std.Dev.
#> persons (Intercept) 1.069 1.034
#> Number of obs: 250, groups: persons, 4
#>
#> Conditional model:
#> Estimate Std. Error z value Pr(>|z|)
#> (Intercept) 1.5875 0.4173 3.804 0.000142 ***
#> ---
#> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#>
#> Zero-inflation model:
#> Estimate Std. Error z value Pr(>|z|)
#> (Intercept) -0.4988 0.5949 -0.839 0.40172
#> child 2.0850 0.3212 6.491 8.52e-11 ***
#> camper1 -1.0863 0.3447 -3.151 0.00163 **
#> ---
#> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Created on 2024-06-14 with reprex v2.1.0
Presumably it would be
formula = count ~ 1 + (1 | persons),
ziformula = ~1 + (1 | persons)
?
As a follow-up of #877
Following families need validation or don't yet work:
Tagging @bbolker FYI (also tagging @bwiernik )
1) How could we possibly validate genpois and compois families? Are there any related families that would return a similar R2 so we have a reference for validating the code?
2) How to calculate the distribution-specific variance for zero-inflated models? (or at least: what's more accurate, see https://github.com/easystats/insight/pull/893#issuecomment-2175532919
3) Is it expected that the R2 is lower for zero-inflated models, when the full model (zero-inflation and conditional part) is taken into account (as opposed to the conditional component of zero-inflated models only, see following example)?
Regarding Zero-Inflation models
Formerly the dispersion parameter for Poisson and ZI Poisson was set to 1. Now, the behaviour for ZI Poisson only has changed, returning a different dispersion / variance:
Taking following model, for this particular example, this comes closer to a Bayesian model than setting sigma/dispersion to 1 (for zero-inflation models!)
Formerly with sigma/dispersion = 1
Now
brms returns (marginal R2 only)
Any ideas how to validate the results? @bbolker @bwiernik ?