Hello there,

I am trying to fit an exponential fit using Least squares to some data.

#data
x <- c(1 ,10,  20,  30,  40,  50,  60,  70,  80,  90, 100)
y <- c(0.033823,  0.014779,  0.004698,  0.001584, -0.002017, -0.003436,
-0.000006, -0.004626, -0.004626, -0.004626, -0.004626)

sub <- data.frame(x,y)

#If model is y = a*exp(-x) + b then
fit <- nls(y ~ a*exp(-x) + b, data = sub, start = list(a = 0, b = 0), trace
= TRUE)

This works well. However, if I want to fit the model : y = a*exp(-mx)+c then
I try -
fit <- nls(y ~ a*exp(-m*x) + b, data = sub, start = list(a = 0, b = 0, m=
0), trace = TRUE)

It fails and I get the following error -
Error in nlsModel(formula, mf, start, wts) :
  singular gradient matrix at initial parameter estimates

Any suggestions how I can fix this? Also next I want to try to fit a sum of
2 exponentials to this data. So the new model would be  y = a*exp[(-m1+
m2)*x]+c . Any suggestion how I can do this... Any help would be most
appreciated. Thanks in advance.

Diviya

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to