Documentation

41.16 Case 4: a fit that recovers, and what to check afterwards

A fit that recovers: attempt 0 and attempt 1

What you will learn

  • Recognise a starting value that cannot work, and see what a bad start does to a fit.
  • Read the retry ledger (retries.csv) and decide which folder holds the result to use.
  • Explain why a nearly identical OFV does not make a non-converged attempt converged.
  • Review a converged retry for boundary and conditioning warnings.

Prerequisites: 41.13 and Chapter 20, the retry pages.

The question: what if the first attempt does not converge?

The evidence: the Chapter 20 retry bundle (the folder retry_worked_… under documents/ch20/results), produced from run20_retry.ctl, which is run20.ctl with one change.

The deliberate fault

The only difference between the working control stream and this one is the first line of $THETA:

(0, 4, 30) ; CL L/h                                         ← run20.ctl
0 ; CL L/h — deliberately unusable because $PK takes LOG(THETA(1))   ← run20_retry.ctl

$PK computes MU_1 = LOG(THETA(1)). A starting value of zero means log(0), which is minus infinity: the model cannot even be evaluated at its starting point as written. A real analysis does not do this on purpose, but an analyst does start CL at 0 by mistake, or at a value in the wrong units, and the run that follows is the one this case studies. The command, with a limit of 65 iterations per attempt, up to three retries and a fixed seed, is recorded in the bundle:

nlmx fit run20_retry.ctl --max-iterations 65 --retry 3 --seed 20261110 --plots --plot-format both

Attempt 0

Termination        : MINIMIZATION NOT COMPLETED — iteration limit (65) reached
Iterations         : 65 (993 objective evaluations)
Final max gradient : 4.006e-2 (internal scale)
Initial OFV        : 725.5085
OBJECTIVE FUNCTION VALUE (OFV): -423.6679

Notice three things. The initial OFV is +725.5, far above the −414.2 of the sensible start. The optimiser then does a great deal of work to climb down: 993 objective evaluations against 255 for the clean run, and it reaches an OFV of −423.6679, within 0.0001 of the reference (−423.6680). And yet the run is not converged: it ran out of iterations with a gradient of 0.04, forty times the 1 × 10⁻³ criterion.

The covariance step completed (condition number 23.7, against 24.1 in the clean run), and its standard errors are almost the same as in page 41.13. This is the trap. Every number in the table of estimates looks right; the termination line says the optimiser had not finished. A completed covariance step does not change the status of the fit.

The ledger

attempt,starting_values,folder,status,ofv,converged
0,the initial values of the control stream,.,not converged,-423.6678906408737,false
1,autoinit estimates of the dataset,retries/retry_01,converged,-423.6680281283035,true

The retry machinery starts only after attempt 0 is marked non-converged. Attempt 1 replaces the control stream's starting values by autoinit estimates of the dataset (the same procedure as page 41.10): CL moves from 0 to about 3.86, V from 45 to 42.5, KA from 1.2 to 1.16. It converges, by a stable relative OFV change, at −423.6680, and the loop stops: retries 2 and 3 were not needed. The two rows are the whole audit trail: what was tried, in what order, with what start, and what each ended as.

Which folder is the result?

This is where analysts go wrong. The parent folder holds attempt 0, so its fit_summary.txt says "NOT COMPLETED" and its final control stream is the end of a non-converged run. The converged attempt is in retries/retry_01/, which is an ordinary fit bundle with its own summary, estimates, checksums and plots. Downstream work (covariate analysis, simulation, the report) must start from the winner's folder, identified by the ledger row with converged = true, not from the parent directory by default.

Review the winner as you would any fit

Convergence is where the review begins. The winning fit repeats the pattern of page 41.13:

  • the additive residual SD is on its lower bound (in the parent's table its RSE is 86.6 %);
  • the full correlation-matrix condition number is about 12 000 (the Chapter 20 page for this bundle records 12 111), but about 12.4 when the boundary parameter is set aside.

The contrast says the near-zero additive term accounts for almost all of the ill-conditioning, and the same remedy applies: drop it. A converged retry can still carry a model that needs fixing.

What it teaches about starting values

Starting value Initial OFV Evaluations Outcome
sensible (page 41.13) −414.2 255 converged in 17 iterations
CL = 0 (attempt 0) +725.5 993 OFV right, not converged at 65 iterations
autoinit estimates (attempt 1) not tabulated not tabulated converged (63 iterations, per the Chapter 20 page)

The optimiser is robust enough to recover from a poor start. The cost is time and a convergence flag you do not control. The cure is cheap: take starting values from the data (Chapter 16) rather than from a template.

The decision

Question Evidence Decision Reversible?
Is the result in the parent folder usable? termination "iteration limit (65) reached", gradient 4e-2 No: it is attempt 0 yes
Which folder is the result? retries.csv: attempt 1, converged = true retries/retry_01/ yes
What follows? boundary additive error; κ ≈ 12 000 (12.4 without it) Drop the additive error and refit yes

What this case does not show

The ledger here has two rows, because the first retry succeeded. It does not show a run where all retries fail, in which case the program ends with a failure exit status and the parent folder is all there is; that outcome is covered by the troubleshooting pages of Chapter 20 and by the exit-code table of Chapter 39.

Review checklist

  • Did you read the termination line of the folder you intend to use?
  • Does the ledger name a converged row, and are you using that folder?
  • Did you check the winner for boundary parameters and conditioning?
  • Are your starting values taken from the data, not from a template?

See the previous page, the next page and the complete case-study reference.