Skip to content
Discussion options

You must be logged in to vote

In the Gelman/Hill book, and in the documentation, it says:

The residuals values from logistic regression (observed values minus expected values).

However, the example from arm::binnedplot() uses resid(), which defaults to deviance residuals.

But observed minus expected would indeed be "response". We should probably change the default, especially since you have a nice simulation example that shows this.

library(performance)

set.seed(1)
n <- 5000
x <- runif(n, 0, 10)

logit_true <- -2 + 0.4 * x 
y <- rbinom(n, 1, plogis(logit_true))

df <- data.frame(x = x, y = y)
model <- glm(y ~ x, data = df, family = binomial)
arm::binnedplot(predict(model), resid(model), sqrt(n))

Created on 2026-08…

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by rbcavanaugh
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants