[R] starting point for non linear fitting

nelson - nelson1977 at gmail.com
Thu Sep 28 10:33:36 CEST 2006


Hi all!
 i'm trying to use nls for fitting my data. I wrote this code to find
some minimum, but it fails, returning 0 every time..... and i can't
figure out the problem... any advice?

grid <- expand.grid(A0 = seq(1000,10000,1000), A1 = seq(0,2,0.1))
exp.approx <- function(x,A0,A1) {
  A0 * exp(- x*A1)
}
ss <- function(p) {
                   sum((durata.h.freq - exp.approx(durata.h.x,p[0],p[1]))^2)}

idx <- which.min(apply(grid,1,ss))



idx is always 1,1... and that's not true...



More information about the R-help mailing list