Check the function nlsList in package nlme.  It does something very
like what you want to do.

"r.ghezzo" <[EMAIL PROTECTED]> writes:

> Hello, I have a program with this section:
> ..
> for(i in 1:20){
>    lo <- nls(y~y0+a/(1+(x/x0)^b),start=list(y0=0.1,a=a0,x0=x00,b=-8.1))
>    beta[i] <- lo$m$getPars()[4]
> }
> ..
> If the fit works this is OK but if the fit fails, the whole program
> fails so:
> 
> ..
> for(i in 1:20){
>    try(lo <-
> 
> nls(y~y0+a/(1+(x/x0)^b),start=list(y0=0.1,a=a0,x0=x00,b=-8.1)))
>    beta[i] <- lo$m$getPars()[4]
> }

It is not a good idea to use lo$m$getPars() directly.  It is better to
use the generic function, which in this case is coef(), as in

coef(lo)[4]

______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to