# Logistic regression diagnostic plots in R

For testing purposes I made up some correlated data in R like this:

mydata = data.frame(
outcome   = c(1, 0, 1, 0, 0, 1, 1, 0, 1, 1),
predictor = c(0.1, -0.2, 0, 0.1, -0.3, 0.3, 0.2, -0.1, 0.1, 0.1)
)


Then I did this in order to create a logistic model that modeled this data:

model1 = glm(family = binomial, formula = outcome ~ predictor, data = mydata)


Running plot(model1) yields the following plots:  I need answers to some questions in order to understand how to perform diagnostics on such a logistic model. As someone with only an introductory course in statistics I'm having trouble gathering knowledge on how to interpret the plots.

1. What do the "Predicted Values" in the first plot represent?
2. What does residual mean in the context of logistic regression?
3. Which of these plots can in any way be useful for model diagnostics based on real data? How?

This question is related to: Interpretation of plot(glm.model), which it may benefit you to read. Regarding your specific questions:

1. What constitutes a predicted value in logistic regression is a tricky subject. That's because the prediction can be made on several different scales. I think the most intuitive predicted value is the fitted probability of 'success' for the given observation. However, you could also use the fitted odds, or the fitted log odds. The fitted model equation / coefficients that is returned by statistical software will be on the scale of the linear predictor, that is, on the log odds scale. As a result, the fitted log odds of 'success' is typically used as the default. In R, for example, ?predict.glm will default to type="link" (the log odds); since your predicted values extend below $0$, it is clear that the log odds of success is what is being plotted.

2. Likewise, what constitutes a residual in logistic regression is even more tricky. There are lots of ways to compute residuals for a generalized linear model. In my opinion, the most intuitive residual would be the raw residual ($r_i = y_i - \hat y_i$), but they are actually hard to use, so you may well never see them. By default, ?residuals.glm defaults to type="deviance". Deviance residuals reflect a datum's contribution to the model's total deviance. Deviance residuals (and some other common types) are briefly discussed in the lecture notes for Germán Rodríguez's GLM class.