# Non-linear regression fails to converge, but fit appears good

I'm fitting a 4 parameter nonlinear regression model to multiple datasets, some of which fail to converge, however, the parameters output after a failure provide a fit that looks good, if not exceptional to my (and other's) eyes.

I've explored convergence criteria and they do converge eventually but the visual fit is terrible.

Is there any precedent for taking the visual fit ad ignoring convergence or are there some other things I can try?

I'm fitting a model of the form $\sqrt{c_1 x+c_2\exp(x)^y}/\sqrt{\exp(x)^y}+c_3$ where $y$ is a known constant, using nlminb in R.

• "fails to converge".. "do converge eventually". "a fit that looks good"..."the visual fit is terrible". Sorry, but I'm confused! – onestop Feb 11 '11 at 18:48
• By tweaking convergence criteria I can get the model to converge, but when this happens the plotted function appears to be a much worse fit than the unconverged results. Presumably due to very large convergence criteria. – R_usr Feb 11 '11 at 20:08

I will assume the values of all the variables and constants are such that there won't be problems with obtaining square roots of negative numbers. Then

$$\frac{\sqrt{c_1 x + c_2 \exp(x)^y}}{\sqrt{\exp(x)^y}} + c_3 =\sqrt{c_2 + c_1 x \exp(-y x)} + c_3.$$

When $y \gt 0$ then eventually, for sufficiently large $x$, $\frac{c_1}{c_2} x \exp(-y x)$ gets small and the fit can be closely approximated as

$$(\sqrt{c_2} + c_3) + \frac{c_1}{2 c_2} x \exp(-y x).$$

Otherwise, when $y \lt 0$ and $c_1 \ne 0$, eventually (for largish positive $x$) the value of $c_2$ is inconsequential compared to the exponential and the fit simplifies to

$$\sqrt{c_1 x} \exp(-y x / 2) + c_3.$$

In either case there are redundant parameters: $\sqrt{c_2} + c_3$ can be kept constant while varying $c_2$ because $c_1$ can also be varied to keep $\frac{c_1}{2 c_2}$ constant. In the second case $c_2$ can be freely varied throughout a wide range.

Therefore, in many circumstances you should expect not to be able to identify at least one of these parameters. It sounds like your data are in one of these cases. If so, you might consider eliminating one of the $c_i$ from the model altogether.

Alternatively, consider a reparameterization of the function in the form

$$\alpha \sqrt{1 + \beta y x \exp(-y x)} + \gamma - \alpha$$

($\alpha = \sqrt{c_2}$, $\beta = c_1/(c_2 y)$, $\gamma = c_3+\sqrt{c_2}$).

This might provide enough clues to the minimizer to help it converge.

• Thanks - that seems to make some sense. Embarrassingly my maths isn't good enough to immediately see how you got to teh reparameterisation, but I'll try things out and report back. – R_usr Feb 11 '11 at 20:06
• Hmmm. After much fiddling the solution seemed to be a slight tweak of my y parameter from -0.06 to -0.061 to get convergence for all...However, fewer datasets failed to get convergence using your RHS simplification of the first equation, and all but one converged using the c2=0 simplification. Many thanks. – R_usr Feb 11 '11 at 20:43
• @R_usr Sorry; I was lazy. I edited the penultimate line to show the new parameters in terms of the original ones. – whuber Feb 11 '11 at 21:11
• no need to apologise. If I'm fitting equations I should know how to manipulate them efficiently. – R_usr Feb 11 '11 at 22:09