Fitted-mean balance for logistic regression with an intercept (source code)

= Fitted-mean balance for logistic regression with an intercept

At an interior maximum-likelihood fit of a logistic-regression model containing an intercept, the intercept <score function> is
$$
\frac{\partial\ell}{\partial\beta_0}=\sum_i(y_i-\widehat p_i)=0.
$$
Consequently the sum of the fitted probabilities equals the number of observed successes exactly.