Skip to content
Prev 77830 / 398502 Next

nls and na/Nan/Inf error

This works if you omit the deriv() step.

Use R's options(error=dump.frames) and debugger().  This gives

Browse[1]> rhs
 [1] 0.4330000 0.4272571 0.3994105 0.3594037 0.3270730 0.3104752 0.3000927
 [8] 0.2928445 0.2874249 0.2831787
attr(,"gradient")
              Vr        Vm       alpha        lamda
 [1,] 0.00000000 1.0000000  0.00000000          NaN
 [2,] 0.02815158 0.9718484 -0.04069202  0.001183749
 [3,] 0.16465431 0.8353457 -0.17769291 -0.035591190
 [4,] 0.36076599 0.6392340 -0.24085444 -0.100064577
 [5,] 0.51925014 0.4807499 -0.21793994 -0.136056450
 [6,] 0.60061200 0.3993880 -0.19071160 -0.145267481
 [7,] 0.65150658 0.3484934 -0.17020938 -0.147113828
 [8,] 0.68703698 0.3129630 -0.15471851 -0.146388612
 [9,] 0.71360324 0.2863968 -0.14263118 -0.144660967
[10,] 0.73441811 0.2655819 -0.13290951 -0.142543261

and note the NaN.  Now think about your formula for x = 0: it does not
actually depend on lamda.  The analytical derivative ends up with a
calculation as 0/0.
On Mon, 26 Sep 2005, Tony Meissner wrote: