Skip to content
Prev 319611 / 398506 Next

question about nls

Actually, it likely won't matter where you start. The Gauss-Newton 
direction is nearly always close to 90 degrees from the gradient, as 
seen by turning trace=TRUE in the package nlmrt function nlxb(), which 
does a safeguarded Marquardt calculation. This can be used in place of 
nls(), except you need to put your data in a data frame. It finds a 
solution pretty straightforwardly, though with quite a few iterations 
and function evaluations.

Of course, one may not really want to do any statistics with 4 
observations and 3 parameters, but the problem illustrates the GN vs. 
Marquardt directions.

JN


 > sol<-nlxb(y ~ exp(a + b*x)+d,start=list(a=0,b=0,d=1), data=mydata, 
trace=T)
formula: y ~ exp(a + b * x) + d
lower:[1] -Inf -Inf -Inf
upper:[1] Inf Inf Inf
...snip...
Data variable  y :[1]  0.8  6.5 20.5 45.9
Data variable  x :[1]  60  80 100 120
Start:lamda: 1e-04  SS= 2291.15  at  a = 0  b = 0  d = 1  1 / 0
gradient projection =  -2191.093  g-delta-angle= 90.47372
Stepsize= 1
lamda: 0.001  SS= 4.408283e+55  at  a = -25.29517  b = 0.74465  d = 
-24.29517  2 / 1
gradient projection =  -2168.709  g-delta-angle= 90.48307
Stepsize= 1
lamda: 0.01  SS= 3.986892e+54  at  a = -24.55223  b = 0.7284461  d = 
-23.55223  3 / 1
gradient projection =  -1991.804  g-delta-angle= 90.58199
Stepsize= 1
lamda: 0.1  SS= 2.439544e+46  at  a = -18.71606  b = 0.6010118  d = 
-17.71606  4 / 1
gradient projection =  -1476.935  g-delta-angle= 92.79733
Stepsize= 1
lamda: 1  SS= 4.114152e+23  at  a = -2.883776  b = 0.2505892  d = 
-1.883776  5 / 1
gradient projection =  -954.5234  g-delta-angle= 91.78881
Stepsize= 1
lamda: 10  SS= 39033042903  at  a = 2.918809  b = 0.07709855  d = 
3.918809  6 / 1
gradient projection =  -264.9953  g-delta-angle= 91.41647
Stepsize= 1
<<lamda: 4  SS= 571.451  at  a = 1.023367  b = 0.01762421  d = 2.023367 
  7 / 1
gradient projection =  -60.46016  g-delta-angle= 90.96421
Stepsize= 1
<<lamda: 1.6  SS= 462.3257  at  a = 1.080764  b = 0.0184132  d = 
1.981399  8 / 2
gradient projection =  -56.91866  g-delta-angle= 90.08103
Stepsize= 1
<<lamda: 0.64  SS= 359.6233  at  a = 1.135265  b = 0.01942354  d = 
0.9995471  9 / 3
gradient projection =  -65.90027  g-delta-angle= 90.04527
Stepsize= 1

... snip ...

lamda: 0.2748779  SS= 0.5742948  at  a = -0.1491842  b = 0.03419761  d = 
-6.196575  31 / 20
gradient projection =  -6.998402e-25  g-delta-angle= 90.07554
Stepsize= 1
lamda: 2.748779  SS= 0.5742948  at  a = -0.1491842  b = 0.03419761  d = 
-6.196575  32 / 20
gradient projection =  -2.76834e-25  g-delta-angle= 90.16973
Stepsize= 1
lamda: 27.48779  SS= 0.5742948  at  a = -0.1491842  b = 0.03419761  d = 
-6.196575  33 / 20
gradient projection =  -4.632864e-26  g-delta-angle= 90.08759
Stepsize= 1
No parameter change
On 13-03-15 07:00 AM, r-help-request at r-project.org wrote: