I am trying to find an optimal sigmoid functional that adjust to my data (at the end of this post). But there is an error: Error in nls(cumulativo ~ f(eixox, phi1, phi2, phi3), start = st, data = data, : singular gradient
Any suggestions ?
library("ggplot2")
data<-structure(list(cumulativo = c(2, 3, 17, 191, 819, 1699, 2679,
3907, 5535, 7254, 9226, 11543, 13809, 15542, 16852, 17709, 18246,
18661, 18976, 19256, 19412, 19539, 19639), eixox = 1994:2016),
class = "data.frame", row.names = c(NA, -23L))
plot(cumulativo~eixox, data=data)
st <- list(phi1=20000,phi2=-5,phi3=.0005)
f <- function(x,phi1,phi2,phi3) {phi1/(1 + exp(-phi3 * x - phi2))}
curvaS<-nls(cumulativo~f(eixox,phi1,phi2,phi3),start=st,data=data,trace=TRUE)