0

I am an R newbie trying to fit stable conservative tracer-related values to a particular model accepted by experts. The goal is to get an estimated coefficient value of a. Here is the error I keep getting:

"Error in numericDeriv(form[[3L]], names(ind), env) : Missing value or an infinity produced when evaluating the model"

The data file used in the code is available at: https://github.com/EmmaQin67/CTD-data/blob/main/at4219002_up.txt

Here's my code:

oct30NDRO<-read.table("at4219002_up.txt",header=TRUE,sep="")
zstar<-data.frame(x=oct30NDRO$DepSM,y=oct30NDRO$T090C)
fit = nls(y~(0.3401*(exp(x/a)-1)/(exp(0.127/a)-1)+6.5583), data=zstar, start=list(a=0.5))
print(fit)

I tried to change the start value a couple of times, but no luck. When I changed the start value to a=1, I get another error message:

"number of iterations exceeded maximum of 50"

I'm expecting to get a summary of the nonlinear fit and get the estimated value of parameter a.

Thank you a lot!

  • 2
    For `a = 0.1` the denominator `exp(450/a) - 1` evaluates to `Inf`. This might be the problem. – Martin Gal Mar 28 '22 at 19:22
  • Thank you for your comment, I think I had a unit problem, and now I change that value from 450 to 0.127, but it's still showing the same error. – Qianhui Qin Mar 29 '22 at 04:01
  • Can you please double-check your equation? The core is `(exp(x/a)-1)/(exp(0.127/a)-1)` (the other parameters are just scaling and shifting this bit): assuming that `a` is positive, this describes an *increasing* function of x, not a decreasing function as your data show. It would also help to double-check the other constants, and give us a little bit of context about where they came from ... – Ben Bolker Mar 29 '22 at 14:17

0 Answers0