Reputation: 43
x<-c(3,33,146,227,342,351,353,444,556,571,709,759,836,860,968,1056,1726,1846,1872,1986,2311,2366,2608,2676,3098,3278,3288,4434,5034,5049,5085,5089,5089,5097,5324,5389,5565,5623,6080,6380,6477,6740,7192,7447,7644,7837,7843,7922,8738,10089,10237,10258, 10491,10625,10982,11175,11411,11442,11811,12559,12559,12791,13121,13486,14708,15251,15261,15277,15806,16185,16229,16358,17168,17458,17758,18287,18568,18728,19556,20567,21012,21308,23063,24127,25910,26770,27753,28460,28493, 29361,30085,32408,35338,36799,37642,37654,37915,39715,40580,42015,42045,42188,42296,42296,45406,46653,47596,48296,49171,49416,50145,52042,52489,52875,53321,53443,54433,55381,56463,56485,56560,57042,62551,62651,62661,63732,64103,64893, 71043,74364,75409,76057,81542,82702,84566,88682)
y<-(1:136)
df=data.frame(x,y)
fit<-nls(y ~ (a/c)*(1-exp(-((c*x)/b)))^d, data=df,start=c( a=100,b=10000,c=0.5,d=0.5),algorithm="port",lower=c(a=100,b=1000,c=0.5,d=0.5),upper=c(a=200,b=100000,c=3,d=3))
i am getting this error
Error in nlsModel(formula, mf, start, wts, upper) :
singular gradient matrix at initial parameter estimates
by using package : minpack.lm
library(minpack.lm)
fit<-nlsLM(y ~ (a/c)*(1-exp(-((c*x)/b)))^d, data=df,start=c( a=100,b=10000,c=0.5,d=0.5),algorithm="LM",lower=c(a=100,b=1000,c=0.5,d=0.5),upper=c(a=200,b=100000,c=3,d=3),weights=1/y^2)
i compared the outputs of r with matlab (cftool)..i found matlab gives accurate result and more deviation between the both results..!
why can't nls() do this fit with any of the algorithm- port/plinear/default ?
i created a application where r run in backend front gui is with java.. i can't call minpack.lm because it needed to be installed.. it doesn't come with R. where nls() is already present in R so i can just call nls() and it works fine..
i was not able to fit this nonlinear equation with nls()..is there any way to do this..
thanks in advance..!!
Upvotes: 0
Views: 138
Reputation: 270055
The model parameters are not identifiable. For example, if we double c
that gives the same model as halving a
and b
.
Upvotes: 3