[R] (no subject)

Katharine Mullen kate at few.vu.nl
Thu Apr 10 16:47:24 CEST 2008


I would suggest making your exact data and calls available.

You can get the estimated parameters from nls even in the case that the
convergence criterium is not met by saying warnOnly=TRUE in the control
list.

depending on why you are not getting convergence, you may want to try a
different algorithm for non-linear regression, like that in the package
minpack.lm.

examples:

x <- seq(0,1,length=100)
a <- 1
b <- .5
c <- .2
someData <- a*(1-exp(-b*x^c)) + rnorm(length(x))*.05*max(someData)

a1 <- 1.2
b1 <- .2
c1 <- .1

nls1 <- nls(someData ~ a*(1-exp(-b*x^c)), start=list(a=a1,b=b1,c=c1),
control = list(maxiter = 500, warnOnly = TRUE), trace=TRUE)

library(minpack.lm)

residF <- function(par) someData - par[1]*(1-exp(-par[2]*x^par[3]))

nls2 <- nls.lm(par = c(a1,b1,c1),
     	fn = residF, control = list(maxiter = 500, nprint=1))

plot(x,someData)
lines(x,fitted(nls1),col=2)
res <- coef(nls2)
lines(x,res[1]*(1-exp(-res[2]*x^res[3])),col=3)

On Thu, 10 Apr 2008, Lindsay Banin wrote:

> Subject: nls, step factor 0.000488281 reduced below 'minFactor' of
> 0.000976563
>
> Hi there,
> I'm trying to conduct nls regression using roughly the below code:
>
> nls1 <- nls(y ~ a*(1-exp(-b*x^c)), start=list(a=a1,b=b1,c=c1))
> I checked my start values by plotting the relationship etc. but I kept
> getting an error message saying maximum iterations exceeded. I have
> tried changing these start values, and I heeded advice from other
> threads and ammended my code to include :, control = list(maxiter =
> 500), trace=TRUE)).
> Now I receive an error message saying "step factor 0.000488281 reduced
> below 'minFactor' of 0.000976563".
>
> Any ideas?
> Many thanks in anticipation,
>
> LB
>
> **********************
> Lindsay Banin
> School of Geography
> University of Leeds
> Leeds, LS2 9JT
> UK
> l.banin05 at leeds.ac.uk
> **********************
>
> ______________________________________________
> R-help at 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.
>



More information about the R-help mailing list