Hi there, I am trying to fit the following model with a sum of exponentials -
y ~ Ae^(-md) + B e^(-nd) + c the model has 5 parameters A, b, m, n, c I am using nls to fit the data and I am using DEoptim package to pick the most optimal start values - fm4 <- function(x) x[1] + x[2]*exp(x[3] * -dist) + x[4]*exp(x[5] * -dist) fm5 <- function(x) sum((wcorr-fm4(x))^2) fm6 <- DEoptim(fm5, lower=c(0,0.1,1,0.1,1), upper=c(10e7, 100, 300,100, 300 ), control=list(trace=FALSE)) par2 <- fm6$optim$bestmem names(par2) <- c("c", "A", "n1", "B", "n2") fit2 <- nls(wcorr ~ (c + A*exp(n1 * -dist) + B*exp(n2 * -dist)), start=par2,control =list(maxiter=1000, warnOnly=TRUE)) However, I keep getting the following error - Error in numericDeriv(form[[3L]], names(ind), env) : Missing value or an infinity produced when evaluating the model OR In nls(wcorr ~ (c + A * exp(n1 * -dist) + B * exp(n2 * -dist)), : singular gradient Can anyone suggest how to resolve the problem? Thanks, Priya [[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.