0
$\begingroup$

I'm trying to fit an exponential model using nls, but I don't know how to select the starting values for the parameters. I know this question has been answered multiple times, but I spent some days surfing on forums and I couldn't find the solution for my particular case. Here they showed the very same problem, but the solution of liniarizing the data taking logs doesn't work wor me, because the fit of the transformed data is not linear. I would really appreciate a piece of advice here.

Here an example of my kind of data:

mes1 <- data.frame(CO2=c(354.68, 362.43, 374.12, 380.45, 385.92, 394.19, 400.2, 405.85, 407.81, 410.71, 414.77), time=c(1, 11, 21, 31, 41, 51, 61, 71, 81, 91, 101))

CO2i <- mes1$CO2[1]
Timei <- mes1$time[1]
exp_eq <- function(time,B,CO2i,a,Timei){B + (CO2i- B)^(-a*(Timei-time))}

I know other kind of equations might work better, but I must use this one since is the reference in the field. The only thing I need is estimate the initial values for a and B

m <- nls(CO2 ~ exp_eq(time,B,CO2i,a,Timei)), data = mes1, start = list(B = 1, a = 1))

Many thanks in advance for your support.

$\endgroup$
9
  • $\begingroup$ I found many directly relevant answers by searching and going through the top few hits. $\endgroup$
    – whuber
    Feb 14, 2020 at 16:23
  • $\begingroup$ Many thanks @whuber I've readed carefully the different posts on this topic, but probably because I'm not profficient in R (and probably in statistics) I couldn't find a solution for my data. From this post [link] (stats.stackexchange.com/questions/160552/…) I cannot estimate the initial parameters because one of them appears in two different parts of the model (and also data trend to an assymptot); I found multiple suggestions, but I couldn't make them work in my case. Many thanks in advance for your support. $\endgroup$
    – jbarba
    Feb 17, 2020 at 17:08
  • $\begingroup$ Additionally, my data tends to a limit, so I cannot estimate C.o as min("input")*0.5, as in the example $\endgroup$
    – jbarba
    Feb 17, 2020 at 17:22
  • $\begingroup$ Sure you can--it is, after all, just an estimate to get things started. But you need to assign the estimate to the correct variable: as time increases, the function approaches $B,$ not $C_0,$ in the limit. At the initial time, the function's value is$C_0.$ It's usually a good idea to graph your data and graph the function associated with your initial estimate to make sure they are reasonably close. $\endgroup$
    – whuber
    Feb 17, 2020 at 17:32
  • $\begingroup$ Thanks for your quick reply. I see that when time increases, the function approaches B, and at initial time, the function is CO2i (constant), but I still don't know how to linearize the data for estimating initial values for B and a. Sorry, I feel so dumb. I applied logs at both sides, but I guess B hinders the proper liniarization of the data $\endgroup$
    – jbarba
    Feb 17, 2020 at 17:57

0

Browse other questions tagged or ask your own question.