title: How to fix 'singular gradient matrix at initial parameter estimates' error
body: <p>I have two vectors: </p>
  
  <pre><code>y: 
   [1] 1889 1528 1213 1009  912  777  783  708  644  716  707  644  634  624  625
   [16]  574  616  569  573  577  565  585  528  572  511  494  555  491  520  518
   [31]  476  454  470  440  450  465  436  403  448  473  429  427  434  429  448
   [46]  407  425  386  414  399  415  385  381  404  430  385  418  407  390  375
   [61]  393  410  386  359  410  367  378  367  362  382  392  378  403  353  376
   [76]  357  439  378  395  357  398  379  337  348  342  387  362  365  361  363
   [91]  359  363  379  392  330  376  366  376  363  350  319  332  328  400  369
  [106]  343  401  359  365  357  398  367  344  383  377  362  405  407  384  362
  [121]  361  355  358  380  371  364  410  355  370  341  373  386  339  388  365
  [136]  368  351  360  379  349  358  333  359  334  369  326  373  370  335  382
  [151]  381  339  344  378  367  361  312  348  356  362  357  386  337  378  386
  [166]  358  376  350  354  374  383  339  352  387  351  383  354  386  388  351
  [181]  355  348  400  379  389  366  370  352  353  369  359  366  357  386  346
  [196]  325  362  378  344
  
  and x:
  x&lt;-seq(150e-9,19950e-9,100e-9)
  </code></pre>
  
  <p>I know that there is an exponential relationship between them and that it is of the form:
  y=a*exp(b*x)+c</p>
  
  <p>I am trying to use the non-linear least squares function to fit the data but I keep getting the error: 'Error in nlsModel(formula, mf, start, wts) : 
    singular gradient matrix at initial parameter estimates'</p>
  
  <p>My code is: </p>
  
  <pre><code>plot(x,y)
  mod &lt;- nls(y ~ a*exp( b * x) + c, start = list( a=3000, b = 500000, c=200 ))
  lines(x, predict(mod, list(x = x)))
  </code></pre>
  
  <p>The parameters I have entered are parameters that I know are close to the expected values. Does anyone know what am I doing wrong here?</p>
  
  <p>I have tried various initial values for the parameters a,b, and c, but I always get some kind of error. </p>
  
  <p>Any help appreciated.</p>