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

2013-10-04 Thread Prof J C Nash (U30A)

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 
is bad.


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 
bad things are.


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/10)))

## 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, 
start=strt4, trace=TRUE, masked=c(Asym))


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-requ...@r-project.org wrote:

Message: 40
Date: Thu, 3 Oct 2013 20:49:36 +0200
From:aline.fr...@wsl.ch
To:r-help@r-project.org
Subject: [R] SSweibull() : problems with step factor and singular
gradient
Message-ID:
of669fa420.9ef643ed-onc1257bf9.00676b04-c1257bf9.00676...@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/10))

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â€�, :                         Â
singular gradient

Is there a way to avoid the problem of a singular gradient?

I’d be very glad about helpful comments. Thanks a lot.
Aline
[[alternative HTML version deleted]]


__
R-help@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.


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

2013-10-04 Thread aline . frank
 Dear John Nash

Thank  you very much for your inputs on how to fit a non-linear growth curve  
without running into singular gradient. I wasn't aware of the package  
nlmrt which seems to provide very helpful functions, indeed. I'll try  to 
figure out how nlxb() can be applied to my data (I am not sure yet  wheter I 
can actually apply the same initial parameters for all of my  plants) and also 
how plotting of the fitted curve works with nlxb(). The  easy way of using 
predict(fit) did not work in this case.

In addition, I am still wondering if there is in fact no way of controlling the 
step factor in SSweibull.

Best regards, 
Aline Frank


[[alternative HTML version deleted]]

__
R-help@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.


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

2013-10-03 Thread aline . frank
 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/10))

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”, :                          
singular gradient

Is there a way to avoid the problem of a singular gradient?

I’d be very glad about helpful comments. Thanks a lot.
Aline
[[alternative HTML version deleted]]

__
R-help@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.