nls singular gradient matrix at initial parameter estimates

2.7k Views Asked by At

I'm trying to fit a first zero-order kinetic curve to some data, when I plot the data and add some initial parameters to the model I get a pretty good visual fit but when I run and nls I get the error:

Error in nlsModel(formula, mf, start, wts) : singular gradient matrix at initial parameter estimates

I've played around with the parameters with no success so I simulated some data based on the model and I still get the same error. Any suggestion what might be wrong:

t <- 1:50
CrStart <- 850
CsStart <- 1100
KrStart <- 0.27
KsStart <- 0.0065
y3 <- runif(1,825,875)*(1 - exp(-runif(1,0.25,0.3)*t)) + runif(1,1050,1150)*runif(1,0.00625,0.00675)*t+runif(50,0,100)

plot(t,y3)

m <- nls (y3~Cr*(1 - exp(-Kr*t)) + Cs*Ks*t, start=list(Cr=CrStart,Cs=CsStart,Kr=KrStart,Ks=KsStart))
1

There are 1 best solutions below

1
On BEST ANSWER

Your issue is that the parameters Cs and Ks are confounded; you have too many parameters in your model. There are infinitely many combinations of Cs and Ks that would fit the model.

The solution is to change Cs*Ks to K and solve for K instead. Then K = Cs*Ks.