Why a Failed Fit Needs Diagnosis
A nonlinear likelihood optimizer can stop without producing a trustworthy estimate. It may have evaluated the likelihood outside the model's parameter space, struggled with parameters on very different scales, followed incorrect derivatives, stopped at a constraint, or converged to one of several local optima. These situations are not interchangeable: changing starting values will not repair an invalid likelihood formula, and a boundary estimate is not automatically evidence of a software failure.
The aim is to diagnose the fit before interpreting its coefficients or using its covariance estimates. Begin with the statistical model and the quantity being optimized. For independent observations \(y_1,\ldots,y_n\) with parameter vector \(\theta\), suppose the model specifies valid densities or probability mass functions \(f_i(y_i\mid\theta)\). The likelihood is \(L(\theta)=\prod_{i=1}^n f_i(y_i\mid\theta)\), and the log likelihood is \(\ell(\theta)=\sum_{i=1}^n\log f_i(y_i\mid\theta)\). Each likelihood contribution must be defined and nonnegative on the parameter space; a log-likelihood contribution must be finite wherever the optimizer evaluates it. Numerical checks can assess the computation, but they cannot make an incorrectly specified statistical model valid.
A Reproducible Diagnostic Sequence
The following sequence separates problems that are often mistakenly treated as one generic “convergence issue.” Keep the data, likelihood definition, parameter constraints, software settings, and starting values fixed when comparing checks, unless a particular check explicitly changes one of them.
List restrictions required by the model, such as positive variances or probabilities between zero and one. Check that each parameter vector passed to the objective satisfies them.
Evaluate the log likelihood at the starting point and at several nearby valid points. Check for nonfinite values, overflow, underflow, and abrupt changes that do not match the model.
Rescale poorly scaled predictors or parameters when appropriate, then compare the supplied gradient and, if used, Hessian with numerical approximations at valid points.
Determine whether the estimate is interior or on a boundary. Examine the optimizer's stopping reason, gradient or constrained optimality measure, and any line-search or trust-region warnings.
Compare converged parameter vectors and log likelihoods. Investigate distinct solutions rather than selecting one solely because a routine declared convergence.
Record the final objective, constraints, convergence evidence, sensitivity to starts, and any remaining numerical or inferential limitations.
Invalid Evaluations and Parameter Constraints
A likelihood is only meaningful where the model defines valid probabilities or densities. For example, a Gaussian variance \(v\) must satisfy \(v>0\). If an optimizer proposes \(v\leq 0\), taking a logarithm or evaluating the Gaussian density is not a harmless numerical inconvenience: the proposal is outside the model's parameter space. Returning an arbitrary large penalty may sometimes be a useful computational device, but the penalty is not a likelihood value and should not be confused with one.
When a restriction is simple, a transformation can make invalid proposals impossible. For a positive variance, one may set \(v=\exp(\eta)\), where \(\eta\) is unrestricted. This changes the optimization coordinate, not the statistical model: every finite \(\eta\) gives a positive \(v\). A transformation may affect numerical scaling, and a parameter boundary such as \(v=0\) is not attained by any finite \(\eta\). Constraints therefore still need to be documented and understood.
Worked Example: Detecting an Invalid Variance Evaluation
Suppose, hypothetically, that two independent observations \(y_1=0\) and \(y_2=2\) follow \(N(0,v)\), with the mean fixed at zero and variance \(v>0\). Their squared residuals sum to \(4\), so the log likelihood is
At the valid proposal \(v=0.5\), substitution gives
At the proposed value \(v=-0.5\), the expression contains \(\log(2\pi v)\), whose real value is undefined, and the model does not define a normal density with negative variance. That evaluation must be treated as invalid, not as a very poor but legitimate fit. An optimizer using \(v=\exp(\eta)\) cannot propose a negative variance; for instance, \(\eta=\log(0.5)\) corresponds to \(v=0.5\). The model assumption \(v>0\) is satisfied at that transformed value.
Scaling and Derivative Checks
A numerical optimizer works with parameter coordinates, so parameters with very different magnitudes can cause poorly conditioned updates. Predictors on large scales can contribute to the same problem: changes in one coefficient may have a much larger effect on the fitted values than changes in another. Rescaling can improve numerical behavior, but it does not create information in the data or solve a genuine identification problem.
For a simple illustration, consider the mean function \(\mu_i=a+bx_i\), where \(x_i\) is measured in units near one thousand and \(b\) is correspondingly small. Define \(z_i=x_i/1000\) and \(\gamma=1000b\). Then
The fitted means are exactly unchanged under the conversion. The coefficient \(\gamma\), however, is the change in the mean for a 1,000-unit increase in \(x\), whereas \(b\) is the change for a one-unit increase. The units must be tracked when translating estimates back.
A derivative check asks whether the derivatives supplied to the optimizer match the stated log likelihood. At an interior point, a central finite-difference approximation to the derivative in coordinate \(j\) is
where \(e_j\) changes only coordinate \(j\) and \(h\) is small enough for a local approximation but not so small that rounding error dominates. Compare this approximation with the analytic derivative at several valid points and, when possible, with more than one step size. A mismatch can signal an algebra or coding error, an incorrect derivative convention, or numerical instability. Near a constraint, the finite-difference points must also remain in the valid parameter space.
Worked Example: Checking a Nonlinear Mean Derivative
Consider hypothetical independent Gaussian observations \(y_1=1\) and \(y_2=2\), with known variance \(1\) and mean \(\mu_i(\theta)=\theta^2\). Ignoring constants that do not depend on \(\theta\), the log likelihood is
Differentiating gives \(\ell'(\theta)=-4\theta^3+6\theta\), so \(\ell'(1)=2\). With \(h=0.001\), the central difference is
This agrees closely with the analytic derivative \(2\) at \(\theta=1\), supporting the derivative implementation at that point. It does not prove the implementation is correct everywhere: the same check should be repeated at other valid values, and a Hessian check is appropriate if the optimizer uses second derivatives. The Gaussian model assumption is satisfied here because the variance is fixed at a positive value and both observations have finite real-valued means.
Boundary Solutions and Multiple Modes
A constrained optimum can occur at a boundary even when the unconstrained score is not zero. For a one-dimensional parameter constrained by \(\theta\geq c\), a differentiable log likelihood maximized at \(\hat{\theta}=c\) can have a negative derivative pointing into the feasible region: increasing \(\theta\) locally lowers the objective. Requiring an interior zero score at such a solution is a mistake. Instead, check feasibility and the direction of improvement among permitted values; the relevant optimality conditions are constrained conditions.
A boundary estimate also needs a statistical interpretation. It may be the genuine maximum under the stated constraint, a symptom of a likelihood that keeps improving toward a limiting value, or a consequence of a coding or optimization problem. These possibilities require different follow-up. In particular, ordinary interior standard-error approximations and likelihood-ratio reference distributions need not apply at a boundary; the boundary-parameter material gives the relevant inferential cautions.
Worked Example: Confirming a Constrained Variance Estimate
Suppose, hypothetically, four independent observations have known mean zero and values \(0.2,-0.2,0.1,-0.1\), with Gaussian variance constrained to \(v\geq 0.1\). The squared residual sum is \(S=0.10\), and
The derivative is
The unconstrained maximizer is \(v=S/4=0.025\), which is not feasible. At the permitted boundary \(v=0.1\),
The derivative is negative, so the log likelihood decreases as \(v\) increases from the boundary. Therefore the constrained maximum is \(v=0.1\), not evidence by itself that the optimizer failed. Its log likelihood is \(-2\log(0.2\pi)-0.5\approx 0.4294\). The observations satisfy the stated independent Gaussian model with a positive variance; the constraint, rather than an invalid evaluation, explains why the estimate differs from the unconstrained value.
Nonlinear likelihoods can also have multiple modes. Run the optimizer from starting values that are meaningfully dispersed within the valid parameter space, then compare the converged log likelihoods and parameters. Agreement is reassuring but does not prove a global maximum; disagreement demands investigation. Distinct parameter vectors with nearly identical objective values may reflect symmetry, weak identification, or numerical tolerance, rather than an arithmetic error.
Worked Example: Recognizing Symmetric Modes
For one hypothetical observation \(y=0\), suppose \(Y\mid\theta\sim N(\theta^2-1,1)\), with \(\theta\in\mathbb{R}\). The log likelihood, omitting its constant, is
Its derivative is \(\ell'(\theta)=-2\theta(\theta^2-1)\), so the stationary points are \(\theta=0\) and \(\theta=\pm1\). The second derivative is \(\ell''(\theta)=2-6\theta^2\): at zero it is \(2>0\), a local minimum, and at each of \(1\) and \(-1\) it is \(-4<0\), a local maximum. Both maxima have log likelihood \(0\) after the constant is omitted, and both give mean zero. Thus, starts on different sides can produce different parameter estimates with the same likelihood. Reporting only one output without checking starts could obscure this symmetry; the likelihood comparison shows that the two solutions are equivalent modes in this model, not one better fit than the other.
What to Report and a Common Pitfall
A concise reproducibility record should identify the objective and its parameter space; the starting values and any transformations or scaling; the optimizer and stopping criterion; the final log likelihood; derivative or constrained optimality checks; and what happened across alternative starts. If estimates differ, report the differences and their likelihood values rather than silently selecting a preferred run. If a fit remains sensitive or a numerical check fails, label the estimates provisional and investigate before relying on standard errors or model comparisons.
- Pitfall: treating the software's convergence flag as proof. The wrong reasoning is, “The routine stopped successfully, so the estimate is the maximum.” A stopping flag means only that the routine met its coded stopping rule. Check validity, derivatives, constraints, objective values, and sensitivity to starts.
- Pitfall: treating every boundary estimate as a bug. A constrained optimum can occur at a boundary. Verify the model's constraints and whether feasible movements improve the objective before declaring failure.
- Pitfall: assuming a rescaled fit is a new model. Exact reparameterization preserves fitted values, but coefficient units change. Translate estimates back and state the units used.
Check Your Understanding
Use the model and numerical details in each question to explain the appropriate diagnostic conclusion.
- A likelihood routine proposes a negative value for a parameter that represents a variance. Why is assigning that proposal an ordinary finite log likelihood incorrect, and what parameterization could prevent the proposal?
- A numerical derivative at one interior point is close to the analytic gradient. What does this check support, and what does it not establish?
- A variance estimate equals its imposed lower bound, and the log likelihood decreases for small feasible increases in variance. Why can this be a valid constrained solution?
- Two dispersed starts produce different parameter vectors with the same maximized log likelihood. Give two explanations that should be considered before deciding one fit is wrong.
- Name at least four items that should be recorded to make a nonlinear likelihood fit reproducible and interpretable.