0
$\begingroup$
## you can download the "Daata" object from here 
## https://drive.google.com/file/d/17WNTCwCqpixHf-AdUiOn6IEpmLzAsetA/view

> head(Daata)
  thinning      dista rn
1        1 0.05787222  1
2        1 0.13197649  2
3        1 1.63724360  3
4        1 1.83829279  4
5        1 1.84211536  5
6        1 1.84909713  6

While this code runs without problems...

> nls(rn ~ Asym/(1+exp((xmid-dista)/scal)),
+      data = Daata,
+      start=c(Asym = 55208.08,
+              xmid = 9.384632,
+              scal = 1.702107))
Nonlinear regression model
  model: rn ~ Asym/(1 + exp((xmid - dista)/scal))
   data: Daata
     Asym      xmid      scal 
53073.228     9.368     1.699 
 residual sum-of-squares: 2.07e+11

Number of iterations to convergence: 3 
Achieved convergence tolerance: 8.548e-07

... this one delivers an error

> gnls(rn ~ Asym/(1+exp((xmid-dista)/scal)),
+      data = Daata,
+      start=c(Asym = 55208.08,
+              xmid = 9.384632,
+              scal = 1.702107))
Error in gnls(rn ~ Asym/(1 + exp((xmid - dista)/scal)), data = Daata,  : 
  step halving factor reduced below minimum in NLS step

Can anyone explain to me why?

$\endgroup$

1 Answer 1

1
$\begingroup$

I'm having the same problem with gnls() function. Seeking the solution, I read that the problem is about the model conception don't fit to your data. Possible solutions are use the argument in gnls() function control=gnlscontrol(nlsTol=100) or the gnlscontrol(tolerance=100)

Edit: I tryed with the argument control=gnlsControl (nlsTol=50) and the problem was solved. Reasons to use gnls rather than nls are when the residuals increase when the variance increases. Note that my code has the argument weights with varPower function in which means my data is heteroscedastic and my residuals increases as a power function of the variance.

 model1=gnls(di_d~b1*(h_rel-1)+b2*sin(c*pi*h_rel)+b3*(cotan), 
                                     data = treat_db_pr[[i]],
                                     start =list(b1=b1[i],b2=b2[i],b3=b3[i], c=c.sin[i]), control = gnlsControl(nlsTol = 50),na.action = na.omit, weights = varPower())

I recomend to use nls() instead gnls() if you're not aimed an heteroscedastic or generalized model.

$\endgroup$
1
  • $\begingroup$ Perfect I finally used the nls function, mostly because It allows me to use the SSlogis function (that I found super useful)! $\endgroup$
    – Nicso
    Sep 26, 2019 at 14:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.