I'm trying to fit my data to a user defined Gompertz equation. However, I received an error as follows:
Error in nls(Eq, data = GPdata, start = list(K = 1), algorithm = "default", : singular gradient
I know this probably means my starting value is not good enough for convergence, but is there any way around this other than guessing? I also tried using the nls2 function (brute force), expanding a huge vector of possible K values to try but received the same error.
Here is my code, including sample data.
t = c(0, 2.4, 4, 5.9, 8.3, 10.2, 12, 14.5, 16.1, 17.8, 19, 21.1, 23, 24.7, 26.4, 28.3,
30.4, 32.3, 34.2, 36)
Cells = c(14619994708, 18945074477, 19999450160, 23461507263, 22803949639, 19400861775,
19806214226, 17390826226, 17390826226, 18186961935, 14066488593,
13285017004, 11058253613, 8085853098, 9168523935, 8435042020,
8560592341, 7734294268, 7720887693, 7503367578)
GPdata = data.frame(t, Cells)
Ninf = (1 * 10 ^ 6) * (1 / 0.001)
Eq <- Cells ~ exp(log(Ninf) * (1 - exp(-K * t)))
Gompstart = nls(Eq, data = GPdata, start = list(K = 1),
algorithm = "default", trace = TRUE)
Any help or suggestions would be greatly appreciated.
Thanks!