I believe I understand how logistic regression works, and what it approximates. However, I do not understand how residuals of a logistic regression are calculated, especially when there are no predictors. Consider this simple example using R syntax:
> residuals(glm(cbind(c(1, 2, 4), c(0, 0, 2)) ~ 0, family=binomial))
1 2 3
1.1774100 1.6651092 0.8243762
The first two values make sense: of course the evidence in the 2:0 case is stronger than in the 1:0 case, which should lead to more positive log odds estimation. But how do I get to those particular values? Why don't we get infinity in both 0 cases if we're calculating log(1/0)? The residuals for the 4:2 case are not log(2), they're log(2.28), as I would wrongly predict on using the same logic.
Code showing what's going on would be greatly appreciated.