Created attachment 1139 [details]
zip file with script and data to reproduce bug
In version 2.12.0, function nls (stats package, nonlinear least squares) sometimes fails to return; the R gui then does not respond any more.
This did not occur in versions 2.9.1 and 2.9.2. It occurs infrequently (I spotted 3 cases in 1600 different nls calls) but reproducibly.
In almost all cases when nls returns, the values are somewhat different from those in the earlier versions (at 7th decimal or smaller).
The enclosed script shows a case using algorithm="port", but the same problem also occurs (with other data) with the default Gauss-Newton algorithm
This is highly platform-specific: I presume that 32-bit R is meant,
but we were not told. It works on x86_64 Linux, x64 Windows, i386 Mac OS X,
but they all give different iteration paths (set trace=TRUE to see).
As far as I can tell the starting values are poor and the problem is
not well-conditioned. Numerical instability with such data is a fact
of life, and unless this can be reproduced on a platform more amenable
to Fortran debugging we will not be spending more time on it.
For the record, the most likely change since the long-obsolete R 2.9.x is in
the compiler used: but you could try 2.11.1 to verify this.
However, a hunch that this is due to incorrect assumptions about
computer arithmetic in portsrc.f that would be circumvented by
-ffloat-store seems to have been inspired. The flags have been changed
in 2.12.0 patched.
I tested the fix in R version 2.12.0 Patched (2010-11-01 r53509),
with 250000 calls to nls (60% the Gauss-Newton algorithm, 40% the port algorithm) including the 3 cases where the problem was noted. Everything works fine now - thanks a lot!
And yes, I (have to) work with the Windows 32-bit version