-
-
Notifications
You must be signed in to change notification settings - Fork 87
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
posterior predictive check for binomial glm with matrix response #644
Comments
This comment was marked as outdated.
This comment was marked as outdated.
Thanks for having a look at this. I appear to have given a partial fix. Looking again line 288
would also need to become
so that it was calculated in the same way |
This comment was marked as outdated.
This comment was marked as outdated.
Thank you. That looks how I would expect it to. Would be nice to improve the x-axis label, but not sure what would work and be easy |
After fixing a bug in insight, this is how it would look like with the current implementation, and your suggested fix. set.seed(1)
tot <- rep(10, 100)
suc <- rbinom(100, prob = 0.9, size = tot)
df <- data.frame(tot, suc)
df$prop <- suc / tot
mod1 <- glm(cbind(suc, tot - suc) ~ 1,
family = binomial,
data = df
)
mod2 <- glm(prop ~ 1,
family = binomial,
data = df,
weights = tot
)
mod3 <- glm(cbind(suc, tot) ~ 1,
family = binomial,
data = df
)
mod4 <- glm(am ~ 1,
family = binomial,
data = mtcars
) Mod1Curent (mod1)New (mod1)Mod2Curent (mod2)New (mod2)Mod3Curent (mod3)New (mod3)Mod4Curent (mod4)New (mod4) |
I've noticed that the posterior predictive check for a binomial glm is different depending on whether the response variable is a vector of proportions or a matrix of successes and failures.
Minimal reprex
I was, perhaps mistakenly, expecting these plots to look the same.
In
performance::pp_check.glm
, the result is calculated asThis is generating lots of Inf where the number of failures is zero.
Should this code not be calculating the proportion, with code such as
The text was updated successfully, but these errors were encountered: