"nelson -" <[EMAIL PROTECTED]> writes:
> 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...
Array indexing in R is 1-based, so p[0] is asking for trouble....
--
O__ ---- Peter Dalgaard Ă˜ster Farimagsgade 5, Entr.B
c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907
______________________________________________
[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.