Hello I was trying to estimate the weibull model using nls after putting OLS values as the initial inputs to NLS. I tried multiple times but still i m getting the same error of Error in nlsModel(formula, mf, start, wts) : singular gradient matrix at initial parameter estimates. The Program is as below> vel <- c(1,2,3,4,5,6,7,8,9,10,11,12,13,14) > df <- data.frame(conc, vel) > dfconc vel 1 0.077 1 2 0.328 2 3 0.882 3 4 1.195 4 5 1.884 5 6 3.577 6 7 6.549 7 8 13.000 8 9 33.690 9 10 52.220 10 11 90.140 11 12 166.050 12 13 233.620 13 14 346.890 14> plot(df$vel, df$conc) > para0.st <- c(K=450,+ alpha=0.054,beta=3.398 )> fit0 <- nls(+ conc~ K-(K*exp(-(vel/alpha)^beta)), df, start= para0.st,trace=T) Error in nlsModel(formula, mf, start, wts) : singular gradient matrix at initial parameter estimates I will be highly thankful if some one can please let me know where is the mistake as i m unable to trace it. Thanks Ruchita On Wed, Dec 16, 2009 at 3:18 PM, ruchita gupta <ruchitarg123@gmail.com>wrote:> Hello > > After performing NLS estimates for some sigmoid model(like logistic growth > model and Gompertz growth models), how can we get the RMSE(root mean square > error) and MAPE(mean absolute percentage error) in R statistical tool for > comparison between two models > > Thanks > Ruchita >[[alternative HTML version deleted]]
ruchita gupta <ruchitarg123 <at> gmail.com> writes:> > Hello > > I was trying to estimate the weibull model using nls after putting OLS > values as the initial inputs to NLS. > I tried multiple times but still i m getting the same error of Error in > nlsModel(formula, mf, start, wts) : > singular gradient matrix at initial parameter estimates. > > The Program is as below > > > vel <- c(1,2,3,4,5,6,7,8,9,10,11,12,13,14) > > df <- data.frame(conc, vel) > > df > conc vel > 1 0.077 1 > 2 0.328 2 > 3 0.882 3 > 4 1.195 4 > 5 1.884 5 > 6 3.577 6 > 7 6.549 7 > 8 13.000 8 > 9 33.690 9 > 10 52.220 10 > 11 90.140 11 > 12 166.050 12 > 13 233.620 13 > 14 346.890 14 > > plot(df$vel, df$conc) > > para0.st <- c(K=450, > + alpha=0.054,beta=3.398 ) > > fit0 <- nls( > + conc~ K-(K*exp(-(vel/alpha)^beta)), df, start= para0.st,trace=T) > Error in nlsModel(formula, mf, start, wts) : > singular gradient matrix at initial parameter estimates > > I will be highly thankful if some one can please let me know where is the > mistake as i m unable to trace it. > > Thanks > Ruchita >This is a better fit:> nls(conc~K+alpha*vel^beta,df,start<-c(K=-0.7,alpha=0.0003,beta=5.3),trace=T)349.1687 : -0.7000 0.0003 5.3000 264.4474 : -0.7507993362 0.0002808334 5.3172851705 263.6331 : -0.7559514801 0.0002816438 5.3169303333 263.6331 : -0.7558506044 0.0002816331 5.3169456595 Nonlinear regression model model: conc ~ K + alpha * vel^beta data: df K alpha beta -0.7558506 0.0002816 5.3169457 residual sum-of-squares: 263.6 Number of iterations to convergence: 3 Achieved convergence tolerance: 1.599e-06>---------------------------------------------------------------- Erwin Kalvelagen Amsterdam Optimization Modeling Group erwin at amsterdamoptimization.com http://amsterdamoptimization.com
This only uses 2 parameters instead of 3 and gives quite a good fit:> DF <- structure(list(conc = c(0.077, 0.328, 0.882, 1.195, 1.884, 3.577,+ 6.549, 13, 33.69, 52.22, 90.14, 166.05, 233.62, 346.89), vel 1:14), .Names = c("conc", + "vel"), class = "data.frame", row.names = c(NA, -14L))> > DF.nls <- nls(conc ~ a * exp(b/vel), DF, start = c(a=1, b=1)) > DF.nlsNonlinear regression model model: conc ~ a * exp(b/vel) data: DF a b 35773.97 -65.02 residual sum-of-squares: 249.6 Number of iterations to convergence: 12 Achieved convergence tolerance: 1.410e-06> plot(conc ~ vel, DF) > lines(DF$vel, fitted(DF.nls))On Fri, Dec 18, 2009 at 7:53 AM, ruchita gupta <ruchitarg123 at gmail.com> wrote:> Hello > > I was trying to estimate the weibull model using nls after putting OLS > values as the initial inputs to NLS. > I tried multiple times but still i m getting the same error of Error in > nlsModel(formula, mf, start, wts) : > ?singular gradient matrix at initial parameter estimates. > > The Program is as below > >> vel <- c(1,2,3,4,5,6,7,8,9,10,11,12,13,14) >> df <- data.frame(conc, vel) >> df > ? ? ?conc vel > 1 ? ?0.077 ? 1 > 2 ? ?0.328 ? 2 > 3 ? ?0.882 ? 3 > 4 ? ?1.195 ? 4 > 5 ? ?1.884 ? 5 > 6 ? ?3.577 ? 6 > 7 ? ?6.549 ? 7 > 8 ? 13.000 ? 8 > 9 ? 33.690 ? 9 > 10 ?52.220 ?10 > 11 ?90.140 ?11 > 12 166.050 ?12 > 13 233.620 ?13 > 14 346.890 ?14 >> plot(df$vel, df$conc) >> para0.st <- c(K=450, > + ? ? ? alpha=0.054,beta=3.398 ) >> ?fit0 <- nls( > + ? ? ?conc~ K-(K*exp(-(vel/alpha)^beta)), df, start= para0.st,trace=T) > Error in nlsModel(formula, mf, start, wts) : > ?singular gradient matrix at initial parameter estimates > > > I will be highly thankful if some one can please let me know where is the > mistake as i m unable to trace it. > > Thanks > Ruchita > > On Wed, Dec 16, 2009 at 3:18 PM, ruchita gupta <ruchitarg123 at gmail.com>wrote: > >> Hello >> >> After performing NLS estimates for some sigmoid model(like logistic growth >> model ?and Gompertz growth models), how can we get the RMSE(root mean square >> error) and MAPE(mean absolute percentage error) in ?R statistical tool for >> comparison between two models >> >> Thanks >> Ruchita >> > > ? ? ? ?[[alternative HTML version deleted]] > > ______________________________________________ > 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. >