title: R nls gaussian fit "singular gradient matrix at initial parameter estimates"
body: <p>I tried to fit my data with a gaussian curve using nls. 
  Because that didn't work, i tried to make an  easy example to see what goes wrong:</p>
  
  <pre><code>&gt;x=seq(-4,4,0.1)
  &gt;y=2*dnorm(x-0.4,2)+runif( length(x) , min = -0.01, max = 0.01)
  &gt;df=data.frame(x,y)
  &gt;m &lt;- nls(y ~ k*dnorm(x-mu,sigma), data = df, start = list(k=2,mu=0.4,sigma=2))
  
  Error in nlsModel(formula, mf, start, wts, upper) :   singular gradient 
  matrix at initial parameter estimates
  &gt; m &lt;- nls(y ~ k*dnorm(x-mu,sigma), data = df, start == list(k=1.5,mu=0.4,sigma=2))
  
  Error in nlsModel(formula, mf, start, wts, upper) :   singular gradient 
  matrix at initial parameter estimates
  </code></pre>
  
  <p>Why doesn't this work?</p>