title: How to add noise in R
body: <p>I'm new in R programming. I have a quation and using the nls fucntion of R to estimate some parameters (b1, b2, b3, b4, b5, b6, b7). I have my starting values but somehow I get "singular gradient" error from R. When I chane one or two of my starting values, It works fine. But My starting values should not be changed due to my research paper. I do some research on the web and found out that this situation is originated from the lack of noise. Here is my work code. Does anyboy know how to add noise to this code? Thanks.</p>
  
  <pre><code>    ComputeDi.Bi &lt;- function(hi, d, h, b1, b2, b3, b4, b5, b6, b7){
  
              q &lt;- hi/h
              t &lt;- 1.30/h
              A &lt;- sin(q*3.14/2)
              C &lt;- sin(t*3.14/2)
              B &lt;- log(A)/log(C)
  
              di &lt;- d * (B^(b1+b2*sin(3.14*q/2)+b3*cos(3*3.14*q/2)+b4*sin(3.14*q/2)/q+b5*d+b6*q*(d^0.5)+b7*q*(h^0.5)))
              return(di)
      }
  
  setwd("../Data")
  sylvestris &lt;- read.csv("ScotsPine100Trees_Turkey.csv")
  
  
  
  nlmod.fp.di &lt;- nls(di ~ ComputeDi.Bi(hi, d, h, b1, b2, b3, b4, b5, b6, b7), data = sylvestris, start = c(b1 = 2.16, b2 = -0.070, b3 = 0.031, b4 = -0.95, b5 = 0.0001, b6 = 0.075, b7 = -0.08), control = nls.control(tol = 1e-07))
  summary(nlmod.fp.di, correlation = T)                            
  </code></pre>