title: Nonlinear regression in R shows error
body: <p>I am using the R function <code>nlsLM</code> from the package <code>minpack.LM</code>  and I have the following error.</p>
  
  <p>I generate my own signal with noise, so I know all parameters, which I'am trying to find doing regression analysis using the same function, I've used to generate signal.</p>
  
  <p>The problem is, that <code>nlsLM</code> function runs fine, and it even could find right parameters values, but at last, when it finds them, error appear like this:</p>
  
  <p>It.   23, RSS =    14.4698, Par. =    42.6727    0.78112          1    65.2211    15.6065          1</p>
  
  <p>It.   24, RSS =    14.4698, Par. =     42.671   0.781102          1    65.2212    15.6069          1</p>
  
  <p><strong>Error in stats:::nlsModel(formula, mf, start, wts) : 
    singular gradient matrix at initial parameter estimates</strong></p>
  
  <p>And I do not know what to do.
  Please explain what it could be, and how I could solve it!</p>
  
  <p>Additional information:</p>
  
  <pre><code>#This is how i generate my signal (it is convolution of gaussian with exp(-kt)
  
  set.seed(100)
  
  Yexp=sim_str_exp(error=10)
  
  time=Yexp[[1]]
  
  y=Yexp[[2]]
  
  dataset_nls=data.frame(time,y)
  
  start=c(tau1=.5,beta1=.5,exp_A1=.5,gaus_pos=.5,gaus_width=.5,gaus_A=0.5)
  
  lower=c(tau1=0.01,beta1=0.01,exp_A1=0.01,gaus_pos=0.01,gaus_width=0.01,gaus_A=0.01)
  
  upper=c(tau1=100,beta1=1,exp_A1=1,gaus_pos=100,gaus_width=850,gaus_A=1)
  
  #here i do fitting
  
  FIT=nlsLM(y ~ str_exp_model(time,tau1,beta1,exp_A1,gaus_pos,gaus_width,gaus_A),data=dataset_nls,start=start,lower=lower,upper=upper,trace=TRUE,algorithm="LM",na.action=na.pass,control=nls.lm.control(maxiter=200,nprint=1))
  
  #Model_function
  
  str_exp_model&lt;-function(time, tau1,beta1,exp_A1,gaus_pos,gaus_width,gaus_A){
  F_gen_V&lt;-vector(length=length(time))
  
  F_gaus_V=vector(length=length(time))
  F_exp_V=vector(length=length(time))
  for (i in 1:length(time)) {
  F_gaus_V[i]=gaus_A*exp(-2.77*((i-gaus_pos)/gaus_width)^2)
  F_exp_V[i]=exp_A1*exp(-1*(i/tau1)^beta1)
  }
  
  convolve(F_gaus_V, F_exp_V,FALSE)
  }
  </code></pre>
  
  <h1>function for signal generation</h1>
  
  <pre><code>sim_str_exp&lt;- function(num_points=512,time_scale=512,tau1=45,beta1=.80,exp_A1=1,gaus_pos=65, 
  </code></pre>
  
  <p>gaus_width=15, gaus_A=1,Y0=0, error=2.0, show_graph=TRUE, norm="False"){</p>
  
  <pre><code>F_gen_V&lt;-vector(length=num_points)
  time_gen_V&lt;-vector(length=num_points)
  F_gaus_V=vector(length=num_points)
  F_exp_V=vector(length=num_points)
  ts=time_scale/num_points
  sigma=vector(length=num_points)
  
  
  for (i in 1:num_points) {
  F_gaus_V[i]=gaus_A*exp(-2.77*((i*ts-gaus_pos)/gaus_width)^2)
  F_exp_V[i]=exp_A1*exp(-1*(i*ts/tau1)^beta1)
  time_gen_V[i]=i*ts
  }
  
  F_gen_V&lt;-(convolve(F_gaus_V, F_exp_V,FALSE))+Y0
  
  if(norm==TRUE){
  F_gen_V=F_gen_V/max(F_gen_V)}
  else{;}
  
  error_V=runif(512,-1*error, error)
  
  for(i in 1:num_points){
  F_gen_V[i]=error_V[i]/100*F_gen_V[i]+F_gen_V[i]
  sigma[i]=(error_V[i]/100*F_gen_V[i])
  }
  
  RETURN=list(time=time_gen_V,y=F_gen_V,sigma=sigma)
  
  if (show_graph==TRUE){
  plot(RETURN[[1]],RETURN[[2]], type="l", main="Generated signal with noise",xlab="time,        pixel",ylab="Intensity");}
  else {;}
  
  return(RETURN)
  
  }
  </code></pre>