From scs10@st-and.ac.uk  Thu May  9 14:46:20 2002
From: scs10@st-and.ac.uk (scs10@st-and.ac.uk)
Date: Thu, 9 May 2002 15:46:20 +0200 (MET DST)
Subject: [Rd] nls (PR#1533)
Message-ID: <200205091346.PAA22891@pubhealth.ku.dk>

Full_Name: Sophie Smout
Version: 1.5.0
OS: windows 2000, pc
Submission from: (NULL) (138.251.190.17)


I'm finding that nls iterates to the end of its iteration setting and does not
jump out to report convergence even when it has clearly converged. It is also
mis-reporting the number of iterations completed. These may not be
unconnected...

This is an example:

[note - details of my computer, version etc are at the end of this message]

##### some 'data'


> x
 [1]  1  2  3  4  5  6  7  8  9 10

> y
 [1] 0.9090909 2.8571429 4.7368421 6.1538462 7.1428571 7.8260870 8.3050847
 [8] 8.6486486 8.9010989 9.0909091

### call to nls

> nls(y~a*x^m/(1+b*x^m),start=list(a=1.1,m=2.1,b=.11),trace=TRUE)

### nls spits out

1.474151 :  1.10 2.10 0.11 
0.01060234 :  1.0092752 1.9893808 0.1012907 
5.066689e-07 :  0.9999465 2.0000191 0.0999903 
3.651161e-15 :  1.0 2.0 0.1 
1.518557e-29 :  1.0 2.0 0.1 
8.09815e-30 :  1.0 2.0 0.1 
8.09815e-30 :  1.0 2.0 0.1 
8.09815e-30 :  1.0 2.0 0.1 
8.09815e-30 :  1.0 2.0 0.1 
8.09815e-30 :  1.0 2.0 0.1 
8.09815e-30 :  1.0 2.0 0.1 
8.09815e-30 :  1.0 2.0 0.1 
8.09815e-30 :  1.0 2.0 0.1 
8.09815e-30 :  1.0 2.0 0.1 
8.09815e-30 :  1.0 2.0 0.1 
8.09815e-30 :  1.0 2.0 0.1 
8.09815e-30 :  1.0 2.0 0.1 
8.09815e-30 :  1.0 2.0 0.1 
8.09815e-30 :  1.0 2.0 0.1 
8.09815e-30 :  1.0 2.0 0.1 
8.09815e-30 :  1.0 2.0 0.1 
8.09815e-30 :  1.0 2.0 0.1 
8.09815e-30 :  1.0 2.0 0.1 
8.09815e-30 :  1.0 2.0 0.1 
8.09815e-30 :  1.0 2.0 0.1 
8.09815e-30 :  1.0 2.0 0.1 
8.09815e-30 :  1.0 2.0 0.1 
8.09815e-30 :  1.0 2.0 0.1 
8.09815e-30 :  1.0 2.0 0.1 
8.09815e-30 :  1.0 2.0 0.1 
8.09815e-30 :  1.0 2.0 0.1 
8.09815e-30 :  1.0 2.0 0.1 
8.09815e-30 :  1.0 2.0 0.1 
8.09815e-30 :  1.0 2.0 0.1 
8.09815e-30 :  1.0 2.0 0.1 
8.09815e-30 :  1.0 2.0 0.1 
8.09815e-30 :  1.0 2.0 0.1 
8.09815e-30 :  1.0 2.0 0.1 
8.09815e-30 :  1.0 2.0 0.1 
8.09815e-30 :  1.0 2.0 0.1 
8.09815e-30 :  1.0 2.0 0.1 
8.09815e-30 :  1.0 2.0 0.1 
8.09815e-30 :  1.0 2.0 0.1 
8.09815e-30 :  1.0 2.0 0.1 
8.09815e-30 :  1.0 2.0 0.1 
8.09815e-30 :  1.0 2.0 0.1 
8.09815e-30 :  1.0 2.0 0.1 
8.09815e-30 :  1.0 2.0 0.1 
8.09815e-30 :  1.0 2.0 0.1 
8.09815e-30 :  1.0 2.0 0.1 
8.09815e-30 :  1.0 2.0 0.1 
Error in nls(y ~ a * x^m/(1 + b * x^m), start = list(a = 1.1, m = 2.1,  : 
        number of iterations exceeded maximum of 5.27058e-308
> 
### ??? the converged parameter values are correct
### but nls has not reported convergence. Instead it's just gone on iterating,
### but not 5.27058e-308 times, which would in any case be tricky...



### try another simple example
### generate some data 



> x<-c(1:10)
> y<-3*x^2+1
> y
 [1]   4  13  28  49  76 109 148 193 244 301
> x
 [1]  1  2  3  4  5  6  7  8  9 10

### call to nls


> nls(y~a*x^b+c,start=list(a=1,b=1,c=1))

Error in nls(y ~ a * x^b + c, start = list(a = 1, b = 1, c = 1)) : 
        number of iterations exceeded maximum of 5.27058e-308

### another call to nls with more details requested

> nls(y~a*x^b+c,start=list(a=1,b=1,c=1),trace=TRUE,control=nls.control(maxiter=10))
210232 :  1 1 1 
209552.9 :  0.3814959 1.4296089 1.7349535 
191724.4 :  0.2824096 1.9134931 1.9513585 
165276.9 :  0.4484658 1.9827257 1.8983138 
125378.7 :  0.7671348 1.9977192 1.7865044 
70298.31 :  1.325342 1.999960 1.589895 
17571.14 :  2.162671 2.000005 1.294948 
4.457052e-06 :  3.0000000 1.9999979 0.9999999 
2.200966e-17 :  3 2 1 
6.125505e-27 :  3 2 1 
6.12235e-27 :  3 2 1 
Error in nls(y ~ a * x^b + c, start = list(a = 1, b = 1, c = 1), trace = TRUE, 
: 
        number of iterations exceeded maximum of 5.27058e-308



#### same problem!!
##############################################

here is what I get when I type 'version'
to get details of computer etc.



platform i386-pc-mingw32
arch     i386           
os       mingw32        
system   i386, mingw32  
status                  
major    1              
minor    5.0            
year     2002           
month    04             
day      29             
language R   
###############################################

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


[Rd] nls (PR#1533)
scs10@st-and.ac.uk