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...
______________________________________________
[email protected] 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.