error in a r code for implementing non-linear regression -


i attempted fit following model:

> x<-c(8100,12900,13800,14250,14700,20700,23100,25200,27300,28560,29760,30060,39060,39660,42060, 42660,57720,57840,58200,59400,59700,60900,62100,65400,85200,88200,88800,98400,106800,114900) > y<-c(1:30) > df<-data.frame(x,y) > fit <- nls(y ~ a*(1-exp(-x/b))^c, data=df, start=c(a=1,b=1,c=1),algorithm="plinear") error in qr.solve(qr.b, cc) : singular matrix 'a' in solve  > fit <- nls(y ~ a*(1-exp(-x/b))^c, data=df, start=c(a=1,b=1,c=1),algorithm="port") error in nlsmodel(formula, mf, start, wts, upper) :    singular gradient matrix @ initial parameter estimates 

but can see got error regarding singular gradient matrix. can avoid error?

the problem estimate of b way off. x ~o(10000), use b=1e4 starting point.

x<-c(8100,12900,13800,14250,14700,20700,23100,25200,27300,28560,29760,30060,39060,39660,4206042660,57720,57840,58200,59400,59700,60900,62100,65400,85200,88200,88800,98400,106800,114900) y<-c(1:30) df<-data.frame(x,y)  fit <- nls(y ~ a*(1-exp(-x/b))^c, data=df, start=c(a=1,b=1e4,c=1),algorithm="port") summary(fit) # formula: y ~ * (1 - exp(-x/b))^c # # parameters: #    estimate std. error t value pr(>|t|)     # 3.357e+01  1.850e+00  18.146  < 2e-16 *** # b 4.295e+04  6.139e+03   6.995 1.61e-07 *** # c 1.725e+00  1.887e-01   9.145 9.33e-10 *** # --- # signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 # # residual standard error: 1.119 on 27 degrees of freedom # # algorithm "port", convergence message: relative convergence (4)   plot(x,y, col="red") lines(x,predict(fit), col="blue") 


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -