Solution (source code)

= Solution

Independence in the <Bernoulli logistic-regression model> gives the <log-likelihood>
$$
\ell(\beta)=\sum_{i=1}^n\left[y_i\beta x_i-\log(1+e^{\beta x_i})\right].
$$
Writing $\mu_i=(1+e^{-\beta x_i})^{-1}$, the <score function> and curvature are
$$
\boxed{\ell'(\beta)=\sum_i x_i(y_i-\mu_i),\qquad
\ell''(\beta)=-\sum_i x_i^2\mu_i(1-\mu_i).}
$$
Thus a finite <maximum-likelihood estimate> solves $\sum_i x_i(y_i-\widehat\mu_i)=0$. If at least one $x_i\ne0$, the curvature is strictly negative for finite $\beta$, so any such solution is the unique maximizer.

Use the <Newton method>, which here coincides with <Fisher scoring> because the second derivative does not depend on the observed responses:
$$
\beta_{k+1}=\beta_k+
\frac{\sum_i x_i(y_i-\mu_i(\beta_k))}{\sum_i x_i^2\mu_i(\beta_k)(1-\mu_i(\beta_k))}.
$$
Step damping or a bracket for the monotone score provides reliable numerical convergence. If all covariates are zero the parameter is unidentifiable; if the outcomes are separated in the direction of the covariates, the likelihood supremum may occur at $\beta=+\infty$ or $-\infty$ rather than at a finite estimate.