title: Using nls in R, error message: Missing value or an infinity produced when evaluating the model
body: <pre><code>&gt; lenss
      xd      yd      zd
  1   0.0000  0.0000 2.44479
  2   0.0937  0.0000 2.73183
  3   0.3750  0.0000 2.97785
  4   0.8437  0.0000 3.18626
  5   1.5000  0.0000 3.36123
  6   2.3437  0.0000 3.50624
  7   3.3750  0.0000 3.62511
  8   4.5937  0.0000 3.72124
  9   5.9999  0.0000 3.79778
  10  7.5936  0.0000 3.85744
  11  9.3749  0.0000 3.90241
  12 11.3436  0.0000 3.93590
  13 13.4998  0.0000 3.96011
  14 15.8435  0.0000 3.97648
  15 18.3748  0.0000 3.98236
  16 21.0935  0.0000 3.99406
  17 23.9997  0.0000 3.99732
  18 27.0934  0.0000 3.99911
  19 30.3746  0.0000 4.00004
  20 33.8433  0.0000 4.00005
  21 37.4995  0.0000 4.00006
  22  0.0663  0.0663 3.99973
  23  0.2652  0.2652 3.99988
  24  0.5966  0.5966 3.99931
  25  1.0606  1.0606 3.99740
  26  1.6573  1.6573 3.99375
  27  2.3865  2.3865 3.98732
  28  3.2482  3.2482 3.97640
  29  4.2426  4.2426 3.95999
  30  5.3695  5.3695 3.93598
  31  6.6290  6.6290 3.90258
  32  8.0211  8.0211 3.85171
  33  9.5458  9.5458 3.79754
  34 11.2031 11.2031 3.72156
  35 12.9929 12.9929 3.62538
  36 14.9153 14.9153 3.50636
  37 16.9703 16.9703 3.36129
  38 19.1579 19.1579 3.18622
  39 21.4781 21.4781 2.97802
  40 23.9308 23.9308 2.73206
  41 26.5162 26.5162 2.44464
  &gt; rd=sqrt(xd^2+yd^2)
  &gt; fit=nls(zd~(rd^2/R)/(1+sqrt(1-(1+k)*rd^2/R^2))+d,start=list(R=75,k=-1,d=1))
  Error in numericDeriv(form[[3L]], names(ind), env) : 
  Missing value or an infinity produced when evaluating the model
  In addition: Warning message:
  In sqrt(1 - (1 + k) * rd^2/R^2) : NaNs produced
  </code></pre>
  
  <p>The function of that model was given above. The question states that there are a few inaccurate measurements in the data and I need to find them. I was going to fit the model first and work out every residuals in every measurement.</p>