# [R] SSweibull() : problems with step factor and singular gradient

Prof J C Nash (U30A) nashjc at uottawa.ca
Fri Oct 4 15:28:57 CEST 2013

```I think you have chosen a model that is ill-suited to the data.

My initial thoughts were simply that the issue was the usual nls()
"singular gradient" (actually jacobian if you want to be understood in
the optimization community) woes, but in this case the jacobian really

My quick and dirty tries give some insight, but do not provide a
satisfactory answer. Note that the last two columns of the nlxb summary
are the gradient and the Jacobian singular values, so one can see how

days <- c(163,168,170,175,177,182,185,189,196,203,211,217,224)
height <- c(153,161,171,173,176,173,185,192,195,187,195,203,201)
dat <- as.data.frame(cbind(days,height))
fit <- try(nls(y ~ SSweibull(x, Asym, Drop, lrc, pwr), data = dat,
trace=T, control=nls.control(minFactor=1/100000)))
## failed

fdata<-data.frame(x=days, y=height)

require(nlmrt)
strt2<-c(Asym=250, Drop=1, lrc=1, pwr=1)
fit2<-nlxb(y ~ Asym - (Drop * ( exp(-(exp(lrc)*(x^pwr))))), data=fdata,
start=strt2, trace=TRUE)

strt3<-c(Asym=250, Drop=.5, lrc=.1, pwr=2)
fit3<-nlxb(y ~ Asym - (Drop * ( exp(-(exp(lrc)*(x^pwr))))), data=fdata,
start=strt3, trace=TRUE)

strt4<-c(Asym=200, Drop=.5, lrc=.1, pwr=2)
fit4<-nlxb(y ~ Asym - (Drop * ( exp(-(exp(lrc)*(x^pwr))))), data=fdata,

d50<-days-160
fd2<-data.frame(x=d50, y=height)
fit5<-nlxb(y ~ Asym - (Drop * ( exp(-(exp(lrc)*(x^pwr))))), data=fd2,
start=strt3, trace=TRUE)
fit5

John Nash

On 13-10-04 02:19 AM, r-help-request at r-project.org wrote:
> Message: 40
> Date: Thu, 3 Oct 2013 20:49:36 +0200
> From:aline.frank at wsl.ch
> To:r-help at r-project.org
> Subject: [R] SSweibull() : problems with step factor and singular
> Message-ID:
> 	<OF669FA420.9EF643ED-ONC1257BF9.00676B04-C1257BF9.00676B07 at wsl.ch>
> Content-Type: text/plain
>
>   SSweibull() : Â problems with step factor and singular gradient
>
> Hello
>
> I  am working with growth data of ~4000 tree seedlings and trying to fit  non-linear Weibull growth curves through the data of each plant. Since  they differ a lot in their shape, initial parameters cannot be set for  all plants. Thatâ€™s why I use the self-starting function SSweibull().
> However, I often got two error messages:
>
> 1)
> # Example
> days <- c(163,168,170,175,177,182,185,189,196,203,211,217,224)
> height <- c(153,161,171,173,176,173,185,192,195,187,195,203,201)
> dat <- as.data.frame(cbind(days,height))
> fit <- nls(y ~ SSweibull(x, Asym, Drop, lrc, pwr), data = dat, trace=T, control=nls.control(minFactor=1/100000))
>
> Error in nls(y ~cbind(1, -exp(-exp(lrc)* x^pwr)), data = xy, algorithm = â€œplinearâ€, : Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â
> step factor 0.000488281 reduced below `minFactor` of 0.000976562
>
> I  tried to avoid this error by reducing the step factor below the  standard minFactor of 1/1024 using the nls.control function (shown in  the example above). However, this didnâ€™t work, as shown in the example  (minFactor still the standard).
> Thus, does nls.control() not work for self-starting functions like SSweibull()? Or is there another explanation?
>
> 2)
> In other cases, a second error message showed up:
>
> Error in nls(y ~cbind(1, -exp(-exp(lrc)* x^pwr)), data = xy, algorithm = â€œplinearâ€, : Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â