insight icon indicating copy to clipboard operation
insight copied to clipboard

`get_variance()` reports incorrect variance for `brms` logit models

Open devincaughey opened this issue 2 years ago • 1 comments

I think that insight::get_variance() reports the incorrect residual variance for logit models from brms (and possibly other packages). It reports the variance as 1 (which is correct for a probit model), but it should be $\pi^2/3$ for bernoulli or ordered logistic models. Based on some quick detective work, it seems that the source of this problem may be insight:::.compute_variance_distribution(), which uses 1 as the default value. See the following lines:

    if (is.null(sig)) 
        sig <- 1

and

        else {
            dist.variance <- sig
        }

devincaughey avatar Mar 14 '23 22:03 devincaughey

Do you have a reproducible example? get_variance() not only includes sigma, but other variance components from mixed models as well. In the case of logistic regression, pi^2/3 is used as distribution-specific variance, see:

https://github.com/easystats/insight/blob/ddb8c4a65d1fa438feae4787cab382486e8933fb/R/compute_variances.R#L504-L515

strengejacke avatar Apr 20 '23 12:04 strengejacke

We have largely revised get_variance(). Feel free to re-open or open a new issue if you still see this problem.

strengejacke avatar Jun 14 '24 10:06 strengejacke