How do you derive the log-likelihood, the gradient and the Hessian of binary logistic regression, show that the log-likelihood is concave, and carry out one Newton step from on the data , (one feature, no intercept)?
Supervised learning, Logistic regression
Level L3 Intermediate. Length Long. Nature Mat Mathematical.
What's being asked
The standard MLE derivation, the identity , why there is no closed form, and a numerical Newton step.
Key idea
With , the gradient is and the Hessian is where . Since the log-likelihood is concave. Newton's method is .
Steps
- Model: with , so .
- Log-likelihood: .
- Use . Then . The cancels the denominators.
- Differentiate again: . For any , , so is concave and any stationary point is a global maximum.
- Setting the gradient to zero has no closed form because depends on non-linearly, so use Newton's method (also called IRLS, iteratively reweighted least squares).
- Numerical step: at all . Gradient . Hessian .
- Newton update: . The positive weight is sensible since larger goes with .
Common mistakes
- Writing the gradient as and then forgetting that depends on , so there is no linear system to solve once.
- Using minimisation signs inconsistently: the Hessian of the log-likelihood is negative semi-definite, of the negative log-likelihood positive.
- Forgetting the weights in the Hessian.
How long your answer should be
One page; 7–8 minutes.
Last checked on 4 December 2026.
Read this
Previous in Supervised learning: Fit a straight line (intercept and slope) to the three points . What are the hat matrix diagonal entries , do they sum to 2, and what is the residual vector?
Next in Supervised learning: For ridge regression, define the effective degrees of freedom and express it with the singular values of . If has singular values and , what are and the shrinkage factor on each direction?