[R] NLS-Weibull-ERROR

Erwin Kalvelagen erwin.kalvelagen at gmail.com
Fri Dec 18 16:49:39 CET 2009


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




More information about the R-help mailing list