nls() throws "step factor reduced below 'minFactor' error even though geom_smooth() using nls() on the same data draws fit curve

45 views Asked by At

I try to get logistic curve fit parameters on following data in fil_dat, I manage to draw curve fit on a plot using ggplot2 geom_curve with nls as method parameter, but when I try to obtain parameters from the model on the same data using nls() function itself I get a "step factor reduced below 'minFactor'" error.

library(ggplot2)

fil_dat <- as.data.table(list(
  wei = c(3.1000, 5.9500, 6.3800, 11.4540, 15.6413, 16.9321, 19.3580, 18.8071, 20.0017, 20.5871, 20.9078, 21.6712),
  age = c(7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84)
))

ggplot(data = fil_dat , aes(x = age , y = wei)) +
  geom_point() +
  geom_smooth( aes(x = age , y = wei , group = NULL ) , 
               method = "nls" , se = F , 
               formula = y ~ Asym/(1+exp((xmid-x)/scal)) , 
               method.args = list(start = list(Asym = 30 , xmid = 5 , scal = 5)))

model <- nls(formula = age ~ Asym/(1+exp((xmid-wei)/scal)) , 
             data = fil_dat , 
             start = list(Asym = 30 , xmid = 5 , scal = 5))

Tried to lower minFactor but then it throws maxiter reached error, when I increase maxiter I get an error bout minFactor again. I'd be grateful for any help how to get those fit parameters.

0

There are 0 answers