Xochitl CORMON
2015-Aug-18 16:08 UTC
[R] Non linear regression - Von Bertalanffy Growth Function - "singular gradient matrix at initial parameter estimates"
Dear all, I am trying to estimate VBGF parameters K and Linf using non linear regression and nls(). First I used a classic approach where I estimate both parameters together as below with "alkdyr" being a subset per year of my age-length-key database and running in a loop. vbgf.par <- nls(Lgtcm ~ Linf *(1 - exp(-K * (Age - tzero))), start = c(K= 0.07, Linf = 177.1), data=alkdyr) I obtain an estimation of both parameters that are strongly correlated. Indeed after plotting Linf ~ K and fitting a linear regression I obtain a function (Linf = a + b*K) with R2= 0.8 and a = 215, b = -763. In this context, to take into account explicitly correlation between parameters, I decided to fit a new non linear regression derivate from VBGF but where Linf is expressed depending on K (I am most interested in K). To do so, I tried this model: vbgf.par <- nls(Lgtcm ~ (a + (b*k)) *(1 - exp(-k * (Age - tzero))), start = c(k= 0.07, a= 215, b=-763), data=alkdyr) Unfortunately at this point I cannot go further as I get the error message "singular gradient matrix at initial parameter estimates". I tried to use alg= plinear (which I am not sure I understand properly yet). If I give a starting value for a and b only, I have an error message stating "step factor below minFactor" (even when minFactor is set to 100000000000). Any help will be more than welcome as this is quite urgent.... Best, Xochitl C. -- <>< <>< <>< <>< Xochitl CORMON +33 (0)3 21 99 56 84 Doctorante en ?cologie marine et science halieutique PhD student in marine ecology and fishery science <>< <>< <>< <>< IFREMER Centre Manche Mer du Nord 150 quai Gambetta 62200 Boulogne-sur-Mer <>< <>< <>< <><
Bert Gunter
2015-Aug-18 16:20 UTC
[R] Non linear regression - Von Bertalanffy Growth Function - "singular gradient matrix at initial parameter estimates"
These appear to be primarily statistics/nonlinear optimization issues that are off topic here, which is about R programming. Post on a statistics list like stats.stackexchange.com instead. Cheers, Bert Bert Gunter "Data is not information. Information is not knowledge. And knowledge is certainly not wisdom." -- Clifford Stoll On Tue, Aug 18, 2015 at 9:08 AM, Xochitl CORMON <Xochitl.Cormon at ifremer.fr> wrote:> Dear all, > > I am trying to estimate VBGF parameters K and Linf using non linear > regression and nls(). First I used a classic approach where I estimate both > parameters together as below with "alkdyr" being a subset per year of my > age-length-key database and running in a loop. > > vbgf.par <- nls(Lgtcm ~ Linf *(1 - exp(-K * (Age - tzero))), start = c(K> 0.07, Linf = 177.1), data=alkdyr) > > I obtain an estimation of both parameters that are strongly correlated. > Indeed after plotting Linf ~ K and fitting a linear regression I obtain a > function (Linf = a + b*K) with R2= 0.8 and a = 215, b = -763. > > In this context, to take into account explicitly correlation between > parameters, I decided to fit a new non linear regression derivate from VBGF > but where Linf is expressed depending on K (I am most interested in K). To > do so, I tried this model: > vbgf.par <- nls(Lgtcm ~ (a + (b*k)) *(1 - exp(-k * (Age - tzero))), start > c(k= 0.07, a= 215, b=-763), data=alkdyr) > > Unfortunately at this point I cannot go further as I get the error message > "singular gradient matrix at initial parameter estimates". > > I tried to use alg= plinear (which I am not sure I understand properly yet). > If I give a starting value for a and b only, I have an error message stating > "step factor below minFactor" (even when minFactor is set to 100000000000). > > Any help will be more than welcome as this is quite urgent.... > > Best, > > Xochitl C. > > > > > -- > > <>< <>< <>< <>< > > Xochitl CORMON > +33 (0)3 21 99 56 84 > > Doctorante en ?cologie marine et science halieutique > PhD student in marine ecology and fishery science > > <>< <>< <>< <>< > > IFREMER > Centre Manche Mer du Nord > 150 quai Gambetta > 62200 Boulogne-sur-Mer > > <>< <>< <>< <>< > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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.
ProfJCNash
2015-Aug-19 13:11 UTC
[R] Non linear regression - Von Bertalanffy Growth Function - "singular gradient matrix at initial parameter estimates"
Packages nlmrt or minpack.lm use a Marquardt method. minpack.lm won't proceed if the Jacobian singularity is at the starting point as far as I'm aware, but nlxb in nlmrt can sometimes get going. It has a policy that is aggressive in trying to improve the sum of squares, so will use more effort than nls when both work. JN On 15-08-18 12:08 PM, Xochitl CORMON wrote:> Dear all, > > I am trying to estimate VBGF parameters K and Linf using non linear > regression and nls(). First I used a classic approach where I estimate > both parameters together as below with "alkdyr" being a subset per year > of my age-length-key database and running in a loop. > > vbgf.par <- nls(Lgtcm ~ Linf *(1 - exp(-K * (Age - tzero))), start > c(K= 0.07, Linf = 177.1), data=alkdyr) > > I obtain an estimation of both parameters that are strongly correlated. > Indeed after plotting Linf ~ K and fitting a linear regression I obtain > a function (Linf = a + b*K) with R2= 0.8 and a = 215, b = -763. > > In this context, to take into account explicitly correlation between > parameters, I decided to fit a new non linear regression derivate from > VBGF but where Linf is expressed depending on K (I am most interested in > K). To do so, I tried this model: > vbgf.par <- nls(Lgtcm ~ (a + (b*k)) *(1 - exp(-k * (Age - tzero))), > start = c(k= 0.07, a= 215, b=-763), data=alkdyr) > > Unfortunately at this point I cannot go further as I get the error > message "singular gradient matrix at initial parameter estimates". > > I tried to use alg= plinear (which I am not sure I understand properly > yet). If I give a starting value for a and b only, I have an error > message stating "step factor below minFactor" (even when minFactor is > set to 100000000000). > > Any help will be more than welcome as this is quite urgent.... > > Best, > > Xochitl C. > > > >
Xochitl CORMON
2015-Sep-08 16:40 UTC
[R] Non linear regression - Von Bertalanffy Growth Function - "singular gradient matrix at initial parameter estimates"
Thank you for the tip. Indeed, nlxb in nlmrt works and results are not crazy. I would like however to assess goodness-of-fit (gof) and ultimately to compare it with gof from linear regression (fitted with same variables). Before I used AICc to compare the nls() and lm() fit, however I get now an error message concerning the method loglike and its non compatibility with nlmrt class object. I guess it is because we use now Marquardt method to minimise sum-of square instead of Gauss-Newton? I am right? Or this is just an incompatibility coming between AICc function and nlmrt objects? Is there an R function to do that? Best, Xochitl C. <>< <>< <>< <>< Xochitl CORMON +33 (0)3 21 99 56 84 Doctorante en ?cologie marine et science halieutique PhD student in marine ecology and fishery science <>< <>< <>< <>< IFREMER Centre Manche Mer du Nord 150 quai Gambetta 62200 Boulogne-sur-Mer <>< <>< <>< <>< Le 19/08/2015 15:11, ProfJCNash a ?crit :> Packages nlmrt or minpack.lm use a Marquardt method. minpack.lm won't > proceed if the Jacobian singularity is at the starting point as far as > I'm aware, but nlxb in nlmrt can sometimes get going. It has a policy > that is aggressive in trying to improve the sum of squares, so will use > more effort than nls when both work. > > JN > > On 15-08-18 12:08 PM, Xochitl CORMON wrote: >> Dear all, >> >> I am trying to estimate VBGF parameters K and Linf using non linear >> regression and nls(). First I used a classic approach where I estimate >> both parameters together as below with "alkdyr" being a subset per year >> of my age-length-key database and running in a loop. >> >> vbgf.par <- nls(Lgtcm ~ Linf *(1 - exp(-K * (Age - tzero))), start >> c(K= 0.07, Linf = 177.1), data=alkdyr) >> >> I obtain an estimation of both parameters that are strongly correlated. >> Indeed after plotting Linf ~ K and fitting a linear regression I obtain >> a function (Linf = a + b*K) with R2= 0.8 and a = 215, b = -763. >> >> In this context, to take into account explicitly correlation between >> parameters, I decided to fit a new non linear regression derivate from >> VBGF but where Linf is expressed depending on K (I am most interested in >> K). To do so, I tried this model: >> vbgf.par <- nls(Lgtcm ~ (a + (b*k)) *(1 - exp(-k * (Age - tzero))), >> start = c(k= 0.07, a= 215, b=-763), data=alkdyr) >> >> Unfortunately at this point I cannot go further as I get the error >> message "singular gradient matrix at initial parameter estimates". >> >> I tried to use alg= plinear (which I am not sure I understand properly >> yet). If I give a starting value for a and b only, I have an error >> message stating "step factor below minFactor" (even when minFactor is >> set to 100000000000). >> >> Any help will be more than welcome as this is quite urgent.... >> >> Best, >> >> Xochitl C. >> >> >> >>