Closed Sebastian-Montoya-B closed 10 months ago
I think it must be plogis()
here.
Should be fixed in https://github.com/easystats/insight/commit/62b86f7aaa7c67e7173d6360e9b471e833a52296
library(glmmTMB)
#> Warning in checkDepPackageVersion(dep_pkg = "TMB"): Package version inconsistency detected.
#> glmmTMB was built with TMB version 1.9.6
#> Current TMB version is 1.9.7
#> Please re-install glmmTMB from source or restore original 'TMB' package (see '?reinstalling' for more information)
library(performance)
dfex <- read.csv("d:/Downloads/dfexample.csv")
model <- glmmTMB(response ~ predictor + (1 | random), data = dfex, family = ordbeta)
summary(model)
#> Family: ordbeta ( logit )
#> Formula: response ~ predictor + (1 | random)
#> Data: dfex
#>
#> AIC BIC logLik deviance df.resid
#> -451.1 -433.4 231.5 -463.1 136
#>
#> Random effects:
#>
#> Conditional model:
#> Groups Name Variance Std.Dev.
#> random (Intercept) 0.4193 0.6475
#> Number of obs: 142, groups: random, 3
#>
#> Dispersion parameter for ordbeta family (): 28.9
#>
#> Conditional model:
#> Estimate Std. Error z value Pr(>|z|)
#> (Intercept) -1.78927 0.42482 -4.212 2.53e-05 ***
#> predictor -0.16126 0.05979 -2.697 0.00699 **
#> ---
#> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
r2(model)
#> # R2 for Mixed Models
#>
#> Conditional R2: 0.166
#> Marginal R2: 0.021
Created on 2023-12-03 with reprex v2.0.2
Dear performance developers.
I've been trying to calculate R2 for a GLMM with ordbeta distribution, and I keep getting the following warning:
I tried to find out where the warning came from, and I got to the
.variance_distributional()
function of insight. In this function, mu is being calculated mainly in four steps:where
null_fixef
ends up being the intercept of the model. Since the intercept of my model is negative,stats::qlogis(mu)
produces NaNs, and the distribution-specific variance cannot be calculated. I was wondering whether this is a bug, or R2 simply can't be calculated for ordbeta when the model's intercept is not between [0,1]? Is there something I am missing?Here's an example using the data from the attached csv file: dfexample.csv
And here is the session info:
Thank you very much for your time.