Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get_variance() reports incorrect variance for brms logit models #732

Open
devincaughey opened this issue Mar 14, 2023 · 1 comment
Open
Labels
3 investigators ❔❓ Need to look further into this issue get_variance function specific labels waiting for response 💌 Need more information from people who submitted the issue

Comments

@devincaughey
Copy link

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
        }
@strengejacke
Copy link
Member

strengejacke commented Apr 20, 2023

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:

} else if (faminfo$is_binomial) {
# binomial / bernoulli ----
# --------------------------
dist.variance <- switch(faminfo$link_function,
logit = pi^2 / 3,
probit = 1,
cloglog = ,
clogloglink = pi^2 / 6,
.badlink(faminfo$link_function, faminfo$family, verbose = verbose)
)
} else if (faminfo$is_count) {

@strengejacke strengejacke added waiting for response 💌 Need more information from people who submitted the issue 3 investigators ❔❓ Need to look further into this issue get_variance function specific labels labels May 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3 investigators ❔❓ Need to look further into this issue get_variance function specific labels waiting for response 💌 Need more information from people who submitted the issue
Projects
None yet
Development

No branches or pull requests

2 participants