I'm trying to solve a two-component decay model in R using the nls function, but running into errors. The equation is:
Where t is time, Ctot is C1+C2, and p1 and p2 are known proportions of Ctot.
my data (dd) is:
> head(dd,n=15)
t Ctot
1 0.00 6.62
2 0.33 6.45
3 0.50 6.38
4 0.67 6.44
5 0.83 6.38
6 1.00 6.39
7 1.17 6.35
8 1.33 6.33
9 1.50 6.33
10 1.67 6.28
11 1.83 6.17
12 2.00 6.11
13 2.17 6.07
14 2.33 5.89
15 2.50 5.86
Using nls I have tried:
p1 <- 0.3
p2 <- 0.7
z <- nls(Ctot~(p1*C1*(exp(-k1*t)))+(p2*C2*(exp(-k2*t))), data=dd, start=list(C1=6, C2=0.1, k1=0.01, k2=0.01))
However I am getting:
z <- nls(Ctot~(p1*C1*(exp(-k1*t)))+(p2*C2*(exp(-k2*t))), data=dd, start=list(C1=6, C2=0.1, k1=0.01, k2=0.01))
Error in numericDeriv(form[[3L]], names(ind), env) :
Missing value or an infinity produced when evaluating the model
I would be grateful if anyone has suggestions!