I have such a data set
Df
xy 7.3006667 -0.14383333 -0.8983333 0.02133333 2.7953333 -0.07466667
and I would like to correspond to an exponential function such as y = a * (exp (bx)).
This is what I tried and the error I get
f <- function(x,a,b) {a * exp(b * x)} st <- coef(nls(log(y) ~ log(f(x, a, b)), df, start = c(a = 1, b = -1))) Error in qr.qty(QR, resid) : NA/NaN/Inf in foreign function call (arg 5) In addition: Warning messages: 1: In log(y) : NaNs produced 2: In log(y) : NaNs produced fit <- nls(y ~ f(x, a, b), data = df, start = list(a = st[1], b = st[2])) Error in nls(y ~ exp(a + b * x), data = df, start = list(a = st[1], : singular gradient
I believe that this is due to the fact that the journal is not defined for negative numbers, but I do not know how to solve this.
source share